android application icon id - android

I need to display notification in the status bar with the application icon.
but i didn't find any way to retrieve the application icon id ?
(I currently use the 1.5 SDK)

try using getApplicationIcon from PackageManager.

context.getResources().getIdentifier("icon", "drawable", context.getPackageName());

Related

How use notification icon from React Native app to some RNBridge?

I created a bridge to React Native to work with Oracle-Responsys SDK.
The bridge is working pretty well, but the only thing that I'm stuck is in how can I set the notifications icons from my react native app to this bridge.
Following the documentations from Responsys:
PushIOManager.getInstance(this).setDefaultSmallIcon(R.drawable.emo_im_surprised);
PushIOManager.getInstance(this).setDefaultLargeIcon(R.drawable.emo_im_happy);
Notes: The Integer value must be a resource ID generated by the build system. In the calls above, the icon name represents the Integer value. For example, R.drawable.emo_im_surprised is the Integer value of the icon emo_im_surprised.png that has been placed in the drawable folder.
I got this, but this R.drawable references my bridge`s drawable not the app drawable, how can i use the icons from my app inside my bridge?
I solved this creating this function:
private int getDrawableId(String name) {
String packageName = getReactApplicationContext().getPackageName();
return getReactApplicationContext().getResources().getIdentifier(name, "drawable", packageName);
}
and using it like this:
Integer notificationIcon = getDrawableId("ic_responsys_alt");
pushIOManager.setDefaultSmallIcon(notificationIcon);
with this code, you just need to add an icon called ic_responsys_alt inside app drawable folder.
that's the bridge we developed

How to get a Android System View ID

I find a different problem.
How to get a Android System View ID?
Like time icon, wifi icon ,net icon, power icon at StatusBar?
i think you used it -
public String getAndroidId() {
return (Settings.Secure.getString(mActivity.getContentResolver(),
Settings.Secure.ANDROID_ID)
);
}

App-Icon Create an Overlayinformation (Number)?

How can I clone this behaviour (iOS) on an Android-App?
Technically its definitly possible as I have an app by my own on my Androidphone - its an Email-App with a very similiar indicator on the Icon. (shows the number of unread Emails)
yes you can implement overlay like ios.. by the way it is called badge value.
here is one sample available on github
You just have to add classes in your project and call below lines
View target = findViewById(R.id.target_view);
BadgeView badge = new BadgeView(this, target);
badge.setText("1");
badge.show();
hope it helps.
If you are referring to doing this on the home screen, that is an app widget.

Android icon wrong in App Management app, but correct in Launcher

I have a simple Android app (built with Mono for Android), which has a problem with it's icon.
The icon is correct in Launcher and in Task Switcher, but
In Manage Apps and in Task Manager it's displayed a generic Android icon
I've checked the various density resources and the manifest and they all look correct.
(I'm seeing this on a Galaxy S phone and on a Nexus 7)
Most likely you set the icon property for your activities within AndroidManifest.xml, but did not set it for the application.
It occurs to me, that the app icon is somehow being cached in the app manager, so that deinstalling and reinstalling the app does not always change the icon properly. Rebooting the device could help.
Also i found this post very useful: adding application ids in gradle usually solves the problem.
Open "AndroidMenifest.xml" in the Package Explorer and click on the "Application" tab at the bottom. Look at the "icon" field and enter the location for your icon ( Ex: #drawable/iconimage). Next, go into the "AndroidManifest.xml" tab and look for android:icon=, adding the location to that as well (Ex: android:icon="#drawable/iconimage)
Make sure you have the same icon name in both locations!
Oleg and Collin are both right but for completeness - in a Mono app the icon can be set with attributes on the Application object (if you have one):
[Application(Label = "MyAppName", Icon = "#drawable/icon")]
class MyApp: Application
{ ...

set different icon/image for shortcut ?

I have written a program that can create shortcut of my application in android emulator homescreen.But the problem is when i created the shortcut then it has the default android icon.
My question is how can i change the icon of the shortcut ?
I have used the following line to set the icon
Intent j=new Intent();
j.putExtra(Intent.EXTRA_SHORTCUT_INTENT,i);
j.putExtra(Intent.EXTRA_SHORTCUT_NAME,n);
j.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,R.drawable.icon);
j.putExtra ("duplicate", false);
j.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(j);
The system is not in your context. You therefore need to give more details to send you icon.
see https://github.com/ldo/ShortcutCircus_Android/blob/master/src/Activity2.java
The icon is given by :
Intent.ShortcutIconResource.fromContext(Activity2.this, R.drawable.icon)
Or you could decode the bitmap and use EXTRA_SHORTCUT_ICON instead.
You can do this in two way.
putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,resId);
putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);

Categories

Resources