[Q] How put logo in ActionBar - Java for Android App Development

Hello Guys,
My english is not very good, i'm sorry for that.
I'm developing an app and now i want to have an icon in my actionbar.
i cannot give an example (security from XDA) but de usual icon top left most apps have. Now i only have the title, but on the left side of the title i want the icon.
I tried this:
getActionBar().setIcon(R.drawable.my_icon);
And i tried with android manifest to add: Android:icon and Android:logo to the activity and many other things But none of them works for me.
If i watch videos it looks like the icon should be there by default, but not in my case.
I hope somebody can help me.
Thanks in advance.

meijeringw said:
Hello Guys,
My english is not very good, i'm sorry for that.
I'm developing an app and now i want to have an icon in my actionbar.
i cannot give an example (security from XDA) but de usual icon top left most apps have. Now i only have the title, but on the left side of the title i want the icon.
I tried this:
getActionBar().setIcon(R.drawable.my_icon);
And i tried with android manifest to add: Android:icon and Android:logo to the activity and many other things But none of them works for me.
If i watch videos it looks like the icon should be there by default, but not in my case.
I hope somebody can help me.
Thanks in advance.
Click to expand...
Click to collapse
Are you using the new Toolbar API?

Thats what i think. I'm not sure, how can i check that?
Do you mean AppCombat?

You need to add the android:icon attribute under the application element, not under the activity

Also the design guidelines state that the icon shouldn't be used if you are using the Toolbar API - there are other ways to get your apps branding across to the user.

Thanks for the answers.
But i tried to add the android:icon attribute to the application element instead of the activity element. (And i tried both)
But in none of this situations the icon will appear.
If i look on Google and Youtube i see many people creating a actionbar and have an icon by default. Strange that i don't have this.
I hope that you can help me, thanks.

meijeringw said:
Thanks for the answers.
But i tried to add the android:icon attribute to the application element instead of the activity element. (And i tried both)
But in none of this situations the icon will appear.
If i look on Google and Youtube i see many people creating a actionbar and have an icon by default. Strange that i don't have this.
I hope that you can help me, thanks.
Click to expand...
Click to collapse
ActionBar != Toolbar. By default the new Toolbar API does not have an icon - this is due to the new design spec (Material Design) that the Toolbar was created for.
You need to find out if you are using the new Toolbar API or the old ActionBar API.
If you're using the Toolbar API then as I already said, it goes against the guidelines to have an icon in the Toolbar now as the primary function of it used to be to get the app branding across to the user which there are now other ways to do using material design (using a custom color palette etc).
If you are really stubborn and insist on going against the guidelines you have to use the below code to set an icon on the Toolbar:
Code:
toolbar.setLogo(R.drawable.ic_launcher);

Thanks for your answer, it helped me.
Now i use:
PHP:
getSupportActionBar().setIcon(R.drawable.ic_launcher);
Now i want the left arrow on the left side of the icon, and using:
PHP:
getSupportActionBar().setDisplayShowHomeEnabled(true);
But it won't work. Can you help me with that?
Thanks!

meijeringw said:
Thanks for your answer, it helped me.
Now i use:
PHP:
getSupportActionBar().setIcon(R.drawable.ic_launcher);
Now i want the left arrow on the left side of the icon, and using:
PHP:
getSupportActionBar().setDisplayShowHomeEnabled(true);
But it won't work. Can you help me with that?
Thanks!
Click to expand...
Click to collapse
Add this to your code:
Code:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

Related

Add tray icon?

I need to have a tray icon for my app, up there with EDGE/3G, Battery and Sound-level.
I have tried the opennetcf's Notify class, but it don't do what I want it to.
Googled alot without any solution, doesn't even seem to be a popular request? I suppose this would be quite crucial to many apps!
What I want to do is:
Add an icon up there, when this is clicked, run some code in my app.
Posibility to change the look of the icon at run time, I guess this could be done by deleting and adding the icon again...

Notification toggle on status bar ?????

Hi there
How can I add notification shortcuts ( wifi, bluetooth,.....etc )( like that of CM7 ) to status bar on official froyo rom ?
\
\
\
Thanks in advance
one easy way to do it is to write an app that has persistant notifications that link to those settings. so you will always have a "button" in your notification tray
http://developer.android.com/reference/android/app/NotificationManager.html
Notifications can take different forms:
A persistent icon that goes in the status bar and is accessible through the launcher, (when the user selects it, a designated Intent can be launched)
---------
Let me know if you need more. I can write some sample code when i get home
killersnowman said:
Let me know if you need more. I can write some sample code when i get home
Click to expand...
Click to collapse
already done that: http://forum.xda-developers.com/showthread.php?t=1037817
Looks good, but it's nice to write this stuff your self. Not too hard, good app to learn from.
From something awesome
@killersnowman
What I was talking abt is A persistent icon on status bar.
I thought This could be easy but I was wrong, it's difficult.
If u can simplify the steps, I'll try to do it.
@j4velin
Regarding NT.apk, It's very good app But i wish it has direct access from status bar ( I mean when pressing for ex. WIFI, it opens another screen to activate WIFI )
actually it's not a problem, Just wishing
Thank U very much
I really appreciate your help
You mean like clicking the batter icon or the clock in the status bar and going to those corrosponding settings? There is no method for achieving this. If you try that now you will see that the notification tray starts to slide down.
From something awesome
I mean like the pic.
Maybe someone else knows but im pretty sure that cant be changed or added without modifying or changing the current rom. Or a home screen replacement (never used one so im not sure)..
From something awesome
OK
Thank u so much
wish you best of luck

[Q] Left Signal & Wifi Icons

Does anyone knows how to move signal and wifi icon from right to left ?
What lines should I edit/add in xml ? If you know any thread/tutorial that teaches how to move, don't be hesitate to tell me.
Actually I'm trying to make my statusbar like iOS. Besides, it can also free up some space on the right side.
Thanks for advising/teaching/guiding.
re: modifications
limyuyang said:
Does anyone knows how to move signal and wifi icon from right to left ?
What lines should I edit/add in xml ? If you know any thread/tutorial that teaches how to move, don't be hesitate to tell me.
Actually I'm trying to make my statusbar like iOS. Besides, it can also free up some space on the right side.
Thanks for advising/teaching/guiding.
Click to expand...
Click to collapse
You don't need to edit any XML files.
Go to the play store and download/install Wanam Exposed, it will have those options
for moving clock and a lot of other features not normally found in stock roms.
https://play.google.com/store/apps/details?id=ma.wanam.xposed&hl=en
Read the description of it at the play store, it will tell you how to use it.
Good luck!

[Q] Alliance ROM help - White Text on Grey Backgrounds

HI all,
So I'm at a loss and hoping someone could point me in the right direction. Installed Alliance ROM onto my Verizon Note 3. So far I'm quite impressed with the ability to customize so many aspects of the interface. But my noob status working with android is causing me to get confused. I'm encountering a UI element that is used in popup menus that currently is displaying white text on a light grey background (as seen in the attached images) Could someone show me where to find the adjustment to change that UI element is?
Also I was a fan of the ability to swipe and launch the camera on the Stock ROM, but I was able to set my preferred app on stock. Don't see anything listed under Default Applications, also when I look at the stock camera's App Info, the Clear defaults button is greyed out. I'm unable to choose which app I want to launch since installing this ROM. I found a workaround by setting Shortcuts to Custom and selecting my app that way, but I liked the Stock ROM's grey button as opposed to using the apps actual icon.
Thanks for any help you can send my way,
Josh
Anyone have any ideas about the grey background. I'd appreciate any help, thanks
irJosh said:
Anyone have any ideas about the grey background. I'd appreciate any help, thanks
Click to expand...
Click to collapse
In AllianceRom Custom Settings under Colors, go to Background -> System and you can change the background of most system apps/menus, it is a universal change but you can enable/disable apps effected in the Whitelist menu.
Thanks for the idea! I'm trying but still can't seem to get that gray background to change. Any other thoughts would be appreciated.
irJosh said:
Thanks for the idea! I'm trying but still can't seem to get that gray background to change. Any other thoughts would be appreciated.
Click to expand...
Click to collapse
You could try wiping cache/davlik in SS, or try flashing a theme like All Backs Black. Other than that the only other thing I can think of is wiping/flashing the rom and starting over but that seems like overkill.
From what I know, I asked the same question in the ROM thread and the answer was this is a bug they are gonna have fixed in Build 2.
Thank you so much guys for the ideas and info. I was going crazy trying different combos of settings to get it to change. I'll look into trying a theme. I was already flirting with the idea of having to try doing a full reinstallation. But if its a known bug I can deal with it, the benefits of using this ROM so outweigh the annoyance of the grey menus. Thanks again!

Guide! See Fanspeed, Screenrecorder full HD, 120Hz screen option!

no root required...
Install activity launcher from playstore.
inside activity launcher search and launch:
cn.nubia.theme.local.ThemeActivity
this will show the preinstalled themes. choose "colorfull international" for round icons.
cn.nubia.gamecenter.settings.records.RecordSettingActivity
this will allow to switch the quality of the screenrecorder from sd to full hd.
com.qualcomm.qti.qcolor.QColorActivity
this will let you choose between all 8 color modes of the screen.
cn.nubia.factory.ChooseFpsActivity
here you can enable 120hz for the screen. It will apply once you leave the menu. standard settings and the refreshrate notification won't show the new value.
you can see that 120hz is working by dimming your screen and toggling between 144hz and 120hz and entering recents screen eachtime you changed the value. The brightness of the grey Background in the menu will be different.
To use the standard refreshrate settings again you must enable "default auto Fps" in the hidden menu.
cn.nubia.factory.FactoryTestQuickFan
here you can see the actual fan speed. Yes its + - 15k rpm.
You can create shortcuts to these menus by longpressing on the desired Activity.
Tested on global 4.05 rom.
there are allot more hidden features like battery percentage in status bar, fingerprint calibration settings and battery stats. But they don't seem to work properly.
Great!! thanks.
nadejo said:
cn.nubia.theme.local.ThemeActivity
this will show the preinstalled themes. choose "colorfull international" for round icons.[/U]
Click to expand...
Click to collapse
This right here makes such a huge difference for me, I normally don't like having icons on my home screen, I generally use Linux CLI Laucher and just quickly type in whatever app I want to open, but because you can't change the launcher on this phone, I'm stuck using the default one, so I only have some icons in the dock, and one of those icons is YouTube Studio, which uses a gear icon, and all the rest of the icons that were applied by default for the other dock apps I use are all square so I just had one random icon that didn't match, and this solved that.
This is a golden find right here, really good job on this.
nadejo said:
no root required...
Install activity launcher from playstore.
inside activity launcher search and launch:
cn.nubia.theme.local.ThemeActivity
this will show the preinstalled themes. choose "colorfull international" for round icons.
cn.nubia.gamecenter.settings.records.RecordSettingActivity
this will allow to switch the quality of the screenrecorder from sd to full hd.
com.qualcomm.qti.qcolor.QColorActivity
this will let you choose between all 8 color modes of the screen.
cn.nubia.factory.ChooseFpsActivity
here you can enable 120hz for the screen. It will apply once you leave the menu. standard settings and the refreshrate notification won't show the new value.
you can see that 120hz is working by dimming your screen and toggling between 144hz and 120hz and entering recents screen eachtime you changed the value. The brightness of the grey Background in the menu will be different.
To use the standard refreshrate settings again you must enable "default auto Fps" in the hidden menu.
You can create shortcuts to these menus by longpressing on the desired Activity.
Tested on global 4.05 rom.
there are allot more hidden features like battery percentage in status bar, fingerprint calibration settings and battery stats. But they don't seem to work properly.
Click to expand...
Click to collapse
Just to confirm that the 120Hz is real, can you go to https://testufo.com/ and see what results you get?
Also, can you post the output of "adb shell dumpsys display" ?
MishaalRahman said:
Just to confirm that the 120Hz is real, can you go to https://testufo.com/ and see what results you get?
Also, can you post the output of "adb shell dumpsys display" ?
Click to expand...
Click to collapse
Just tried it does show 120 FPS it does work
Sent from my NX659J using Tapatalk
Guys I changed my theme and I now have the rounded icons. If I want to go back to the default square icons, how do I do that? I deleted cache and data for the launcher but it didn't change the icons back to the default square ones. Any idea?
mhajii210 said:
Guys I changed my theme and I now have the rounded icons. If I want to go back to the default square icons, how do I do that? I deleted cache and data for the launcher but it didn't change the icons back to the default square ones. Any idea?
Click to expand...
Click to collapse
the first theme inside the menu i guess.
I attached the screenshots. It doesn't list any theme or icons that were the original square ones. Any ideas how to go back to the original stock ones?
mhajii210 said:
I attached the screenshots. It doesn't list any theme or icons that were the original square ones. Any ideas how to go back to the original stock ones?
Click to expand...
Click to collapse
"simple clouds" enables the squares. and if you mean they looked differently whic i can't tell i think only a factory reset will restore.
bANONYMOUS said:
This right here makes such a huge difference for me, I normally don't like having icons on my home screen, I generally use Linux CLI Laucher and just quickly type in whatever app I want to open, but because you can't change the launcher on this phone, I'm stuck using the default one, so I only have some icons in the dock, and one of those icons is YouTube Studio, which uses a gear icon, and all the rest of the icons that were applied by default for the other dock apps I use are all square so I just had one random icon that didn't match, and this solved that.
This is a golden find right here, really good job on this.
Click to expand...
Click to collapse
Wait I don't get it, how does changing to round icons make your life so much easier?
I think there's a normal non-hidden interface for screen recording quality under more features > supersnap
ctakah27 said:
I think there's a normal non-hidden interface for screen recording quality under more features > supersnap
Click to expand...
Click to collapse
yes but it doesnt allow 1080 p you can see this by checking details of the Recorded video. it will only be full hd once you choose it in the hidden menu.
Worth noting that you don't need to install activity launcher or anything, really, if you have adb (which my device came with by default(!) but you can get through developer options)
Just make sure to separate package name from activity name, e.g. :
am start-activity -n cn.nubia.theme.local/.ThemeActivity
am start-activity -n com.qualcomm.qti.qcolor/.QColorActivity
etc.
(also works as "adb shell am start-activity -n cn.nubia.theme.local/.ThemeActivity"), etc
morpheus______ said:
Worth noting that you don't need to install activity launcher or anything, really, if you have adb (which my device came with by default(!) but you can get through developer options)
Just make sure to separate package name from activity name, e.g. :
am start-activity -n cn.nubia.theme.local/.ThemeActivity
am start-activity -n com.qualcomm.qti.qcolor/.QColorActivity
etc.
(also works as "adb shell am start-activity -n cn.nubia.theme.local/.ThemeActivity"), etc
Click to expand...
Click to collapse
I'm sure my guide is easier
and you would'nt be able to guess any of these things inside adb. so you need the app in first place to find these things anyways. i dont understand what you try to prove. It doesnt make sense to use adb for such easy things you can do inside an app. it's like you're saying "you dont have to go into settings to turn on wifi i can do it with adb" :silly:
you're just jelly i found this stuff with some guys on telegram and there is no credit for you. you would'nt find anything in your adb if i didnt post this. get your mind right before you say this is worthless. my phone didnt come with adb i don't know whats wrong with your device... don't even bother replying it makes no sense and i will not go further in detail with you.
Wow. No good deed goes unpunished, eh?
Nobody's trying to steal anyone's credit. I'm just saying that some folks like myself who do not want to install anything (so as to keep the device pristine as possible) would maybe like to know of alternate ways to trigger activity. The am way works anywhere, not just on the Nubia activities.
Let go of the jealousy and the flames, man. Just trying to help people out. Take your credit, upvote yourself, be happy. The world has enough strife and complication already to get into pointless bickering.
nadejo said:
I'm sure my guide is easier
and you would'nt be able to guess any of these things inside adb. so you need the app in first place to find these things anyways. i dont understand what you try to prove. It doesnt make sense to use adb for such easy things you can do inside an app. it's like you're saying "you dont have to go into settings to turn on wifi i can do it with adb" :silly:
you're just jelly i found this stuff with some guys on telegram and there is no credit for you. you would'nt find anything in your adb if i didnt post this. get your mind right before you say this is worthless. my phone didnt come with adb i don't know whats wrong with your device... don't even bother replying it makes no sense and i will not go further in detail with you.
Click to expand...
Click to collapse
morpheus______ said:
Wow. No good deed goes unpunished, eh?
Nobody's trying to steal anyone's credit. I'm just saying that some folks like myself who do not want to install anything (so as to keep the device pristine as possible) would maybe like to know of alternate ways to trigger activity. The am way works anywhere, not just on the Nubia activities.
Let go of the jealousy and the flames, man. Just trying to help people out. Take your credit, upvote yourself, be happy. The world has enough strife and complication already to get into pointless bickering.
Click to expand...
Click to collapse
i didnt start the fire (...Worth noting that you don't need to install activity launcher...)
as you see it's worth something, or there were no such commands for you to type inside adb.
made me a lil angry, it's fine.
mhajii210 said:
I attached the screenshots. It doesn't list any theme or icons that were the original square ones. Any ideas how to go back to the original stock ones?
Click to expand...
Click to collapse
I don't have the phone yet, however I'm already trying to catch up.
So are all those icons change possibilities available? they look pretty good.
JeankDragon said:
I don't have the phone yet, however I'm already trying to catch up.
So are all those icons change possibilities available? they look pretty good.
Click to expand...
Click to collapse
Yes. You can follow the instructions on this thread to gain access to the hidden themes already present on the device. Also, you can download the theme.apk app from the Chinese ROM that allows additional options https://forum.xda-developers.com/nu...d-magic-5-software-limitations-t4088015/page4
i spotted a service that will show the actual fan speed. its in the op.

Categories

Resources