I've defined an upload_widget.png file for my app widget, and declared it as below in my AndroidManifest.xml. It worked fine when I first created it, but I've now made a change to the .png image files (in each of /drawable folders), synchronised the files in Android Studio, but the widget icon is not reflecting the new .png files when I re-test the app on my Galaxy S4.
When I long-press on the screen (I'm using Nova Launcher) and select "add widget" I see the correct icon in the "Choose Widget" list, but when I select it I get a different icon on the launcher - i.e. the old icon. When I run the app in a Nexus 5 emulator I get the same problem.
Any ideas??
<receiver android:name=".UploadWidget" android:icon="#drawable/upload_widget" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/upload_widget_info" />
</receiver>
UPDATE
Here is upload_widget_info:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="40dp" android:minHeight="40dp" android:updatePeriodMillis="86400000"
android:previewImage="#drawable/example_appwidget_preview"
android:initialLayout="#layout/upload_widget" android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen|keyguard"
android:initialKeyguardLayout="#layout/upload_widget"></appwidget-provider>
Your code is correct. This is a common problem on devices running Lollipop. To fix it, navigate through these steps : Settings -> Apps -> Google App -> Manage Space -> Clear Launcher Data. Your shortcuts on the homepage will disappear but the widget icon will be correct.
Source: https://code.google.com/p/android/issues/detail?id=81076&thanks=81076&ts=1417102714
Related
My app preview image looks like this:
How can I make it look like the WhatsApp Chat preview, small with shadow. Also other apps in my phone use the same type of preview.
My widget xml:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="#layout/appwidget"
android:minHeight="40dp"
android:minWidth="320dp"
android:previewImage="#mipmap/ic_launcher"
android:updatePeriodMillis="300000" >
</appwidget-provider>
Manifest:
<receiver
android:name=".activities.MyWidgetProvider"
android:label="Example Widget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info" />
</receiver>
UPDATE:
Actually I have noticed this all shortcuts and not widgets, they all have this look.
You have set your launcher icon as widget preview image.
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
...
android:previewImage="#drawable/widget_preview">
</appwidget-provider>
I suggest you to make a screenshot of your widget with the emulator, which has an application (Widget Preview) for creating a preview with just the right size.
Then, you can also edit the picture if you are not satisfied.
Anyway, be sure to put it on drawable-nodpi.
Official guide to follow: https://developer.android.com/guide/topics/appwidgets/index.html#preview
For other dev experience, see this link: Android Widget: previewImage size
It seems that you have placed ic_launcher as widget previewImage
You have to make a custom image, which have large image as Alpha in background, and on it place your icon in small size on top-right corner.
I have done same thing by generating custom image for previewImage with help of photoshop and its working.
Thank you.
This is not a duplicate of Android Application creating two launcher icons (I don't have multiple LAUNCHER definitions in my manifest), nor Android Application Creating Two Launcher Icons instead of One (a restart of the device does not remove the second launcher icon).
My android application is creating two launcher icons, but one of them seems to be coming from the application itself, rather than any activity. I've cropped my AndroidManifest.xml to the smallest it can be (plus clean and rebuild and reinstall), and I am still getting two icons (on both my HTC One M8 physical phone and my Nexus 5 emulator):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
There is nothing else in my manifest.
...does the application itself as I've defined it create an icon somehow? Or is there some other way that I'm ending up with multiple launcher icons?
If I move the android:label and android:icon features into the .SplashActivity definition, one of the launcher icons created is replaced with the default little green robot icon.
Activities and other bits of manifest-y goodness come from a variety of sources:
the manifest in your main sourceset
the manifest in any build type or product flavor sourceset
the manifest in any library module or AAR
Gradle (e.g., minSdkVersion)
Android Studio 2.2 gave us a convenient tool to examine the real manifest that goes into our APKs, merged from all those sources. If you open the manifest in Android Studio, click over on the "Manifest Merger" sub-tab (towards the bottom of the IDE). That will show what is in the merged manifest and who is to blame for it where it came from.
If you see other activities in there besides the one in your manifest, that is the source of your launcher icon. Then, you'll need to decide:
is that activity something you really want?
if not, is the source of that activity something that you really want? (if not, nuke it)
if you want the source but not the activity, you can rig up another activity element in your manifest, with a tools:replace attribute, to override the one from the library and suppress the <intent-filter>
My problem was, that I've added the following intent-filter to multiple Activities. Configured it for one Activity fixed the issue for me.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I am trying to change the launch icon of my already developed android app. I right click on res folder. Go to new --> image asset and change the path given there.
It confirms me that some files will be updated and so on. But my launch icon doesnt change.
On top of that , when I go back to res --> new --> image asset, path has changed itself back to original path:
C:\Program Files\Android\Android Studio1\plugins\android\lib\templates\gradle-projects\NewAndroidModule\root\res\mipmap-xhdpi\ic_launcher.png
The above path is not even a part of my project. I am unable to fiure out , where this is hard coded. Please help.
you can change change an icon, just long press on an app, and this pop-up menu shows up. Tap on Edit. Next, tap on the original icon seen on the left. You can choose a new icon from a pack, or you can create one from the images in your gallery.
You can change icon by installing a custom launcher,
Go to your apps AndroidManifest.xml file and change android:icon attribute with your icon
<application
android:allowBackup="true"
android:icon="#drawable/your_icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
On Android Studio, a right click on the root folder of your app > New > Image Asset > Launcher Icons and setting your new icon should do the trick and overwrite the existing one.
If it doesn't, try removing the asset in your project tree first, and try again. You have to delete every resolution of it!
I've made it like this in my app:
delete every single file in your project called ic_launcher.png
(mostly found in android studio under project->src->res->drawable/mipmap...)
rename your own Icon png to: ic_launcher.png
drag and drop your icon into the folder 'mipmap' or 'drawable', depending where the file previously was, in your android studio project.
done :)
You should add the new icon in all mipmap folders like xxxhdpi,xxhdpi,xhdpi
Firstly add all the application Icon size in mipmap like mdpi, hdpi, xhdpi, xxhdpi and xxxhdpi.After then just place name in android:icon attribute.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
</application>
Actually I am working on music player widgets, I made home widget for music player and it is working fine,but when I play any song I need to show that song image on android lock scren, I tried lockscreen widget but I didn't get it please help me
Home widget:
<receiver android:name=".widgets.HomeWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/app_widget_provider"/>
</receiver>
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="#layout/home_widget_layout"
android:minHeight="10dp"
android:minWidth="250dp"
android:updatePeriodMillis="1000000"
>
</appwidget-provider>
If you want to enable your widgets in lockscreen too you have to set widgetcategory to keygaurd in your manifest as:
<android:widgetCategory="keyguard|home_screen">
You can find detailed documentation in: http://developer.android.com/guide/topics/appwidgets/index.html#lockscreen
Actually Google did away with lock screen widgets in Android 5.0 (Lollipop). If you simply want to display the album art on the lock screen, then let your app implement RemoteControlClient (or MediaSession for API 21 and up)
If you want more functionality, the you can create you own interactive lock screen experience for your users with the Adenda SDK (I'm affiliated with Adenda for full disclosure)
So i developed a widget for android. It all worked fine when i had
default samsung ROM for my sgs3 (android 4.1),
But when i updated my android version to 4.2.2(CM10) i don't see my widget under
'Widgets' category in the android menu.
here is my manifest:
<receiver android:name="ToDoListWidget"
android:label="ToDoList"
android:icon="#drawable/icon" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/items_widget" />
</receiver>
and here is my appwidget-provider:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="#layout/widget"
android:minHeight="100dp"
android:minWidth="320dp"
android:resizeMode="vertical"
android:updatePeriodMillis="100000" >
</appwidget-provider>
Any ideas what should i cahnge?
EDIT:
Hey, please help me with this one, it happend again right now when i
create a widget in another app.
Is the problem in my code? in my device? in my SDK?
I do believe CyanogenMod does this clever thing of moving your app to the SD card automatically if possible
And any app that is on the SD card cannot add a widget to the home screen (as when the SD card is mounted to a PC the widget would disappear and this would be "strange").
So check your app isn't on the SD card. You might want internalOnly or preferInternal in your AndroidManifest.xml