Android widget not showing up on the list after developed - android

I'm upgrading my app with widget. It's not the first widget I've done. I was always encountering weird issues, but the widget was shwoing up on the list eventually.
Here is what I've done so far:
Created widget_layout.xml
Created widget_info.xml
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="110dp"
android:minHeight="30dp"
android:updatePeriodMillis="86400000"
android:initialLayout="#layout/widget_layout"
android:resizeMode="none">
</appwidget-provider>
Created WidgetProvider class
Added widget to manifest in the <application> section (for some reason can't paste manifest fragment here, it's just not showing, see the code here)
Still, can't find widget on the widgets list. I'm debugging the app on real device. I'm using library project, but the widget files but all in the project I run directly. What could be happening here?

Ran across similar issues and this is what happened for me. The below Widget never showed up in the Widget drawer till minResizeHeight was added. Weird, but may be that is required for resizable widget. Could have been more friendly.
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="#layout/pmt_schedule_scroll_widget"
android:minHeight="146dip"
android:minResizeHeight="73dp"
android:minWidth="146dip"
android:resizeMode="vertical"
android:updatePeriodMillis="0" />

This kind of issue can happen with 2 scenarios. Both are answered above and this is a complete answer and I have faced both the scenarios and resolved both of them.
Scenario1
If the application specifies android:installLocation="preferExternal" parameter in manifest, App will be installed in external memory and it will not show in the widget list. Also if you have made your phone to install all the apps on sd card, this will also happen.
solution
Go to Settings->Apps->YourApp
Then "move to phone". This will move the app to your phone memory and now you can see the widget in your widget list
Scenario2
If the above fix did not solve your issue, then you may have a device with android 4.X.X version.
Then you have to set at least following parameters in widget_info.xml file
solution2
android:minHeight="XXXdp"
android:minWidth="XXXdp"

The problem was android:installLocation="preferExternal"
It somehow causes problem with widget list if the app is installed on SD

I tried every possible solution and nothing worked for me...
And finally I solved it.
In my case the problem was overthinking: I believed that in meta-data tag we need to define a unique name for provider (eg: "com.example.myprovider") as well as link to the xml resource.
Wrong:
<meta-data
android:name="com.example.myprovider"
android:resource="#xml/widget_info" />
Right:
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/widget_info" />

You need to register a BroadcastReceiver in the manifest file. For example:
<receiver
android:icon="#drawable/icon"
android:label="Example Widget"
android:name="MyWidgetProvider" >
<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>
I borrowed this code from http://www.vogella.com/articles/AndroidWidgets/article.html
See the link for a full tutorial

after hours of searching and failing to resolve, I decided to open a sample project of a widget that works and go comparing item by item to see what was wrong, in the end, I solve added the following lines on my res/xml/widget_info.xml:
android:minHeight="XXXdp"
android:minResizeHeight="XXXdp"
android:minResizeWidth="XXXdp"
android:minWidth="XXXdp"
where XXX is some value.

In my case, the issue was in the intent-filter within the receiver.
Wrong:
<intent-filter>
<action android:name="APPWIDGET_UPDATE" />
</intent-filter>
Correct:
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>

In my case, it was the minWidth, it was too large, just put a smaller dp, it works also with a minHeight too height as well!

Related

Can't start App from Android Studio with neither Launch Option "Default" nor "Specific" Activity

The problem occurred overnight. One day, everything worked fine. I shut my computer down and started it back up on another day. However, without changing a thing, I tried to launch my App on the same virtual device I had before and somehow it wont launch because:
"Error running 'app'. Default Activity not found."
My manifest looks like this. I changed the package name and the two activities below (see comments below). The rest is exactly the same.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="MyPackageName">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<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">
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:screenOrientation="portrait">
</activity>
<activity android:name=".AnotherActivity" />
<activity android:name=".OneMoreActivity">
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="364e8b3f6acfddf9ad32bed8c1503bb762b19cd5" />
</application>
</manifest>
And normally my app would just start with the Login Activity. However, now it does not. I tried to "Invalidate Caches / Restart". Nothing changed. I restarted AS multiple times. Still, nothing.
Then I tried to change the Launch Options. Current Option was set to "Default Activity". So I tried to change it to a specific one. Namely, the LoginActivity. But then it tells me:
"Error running 'app'. The Activity 'LoginActivity' is not declared in AndroidManifest.xml."
It tells me it's not declared, which it clearly is. Otherwise I wouldn't be able to choose it from the dropdown in the first place. I also tried to start on another Activity. "MainActivity". Still nothing.
What exactly am I doing wrong? Is there maybe a workaround where I can manually get the APK on my virtual device so that I can at least keep working?
Edit
I already tried deleting the .gradle-folder. Sadly this didn't work. I tried pushing it to git and cloning it again in another folder. That didn't work either.
Workaround
So far I've only been able to find a workaround:
Go to Run/Edit Configurations...
Go to General/Launch Options -> Launch: Nothing
Run as you normally would. Android Studio will build the project and install the application to your device, but won't launch it!
Launch your app manually on your device.
Go to Run/Attach Debugger to Android Process.
Choose your app.
Obviously, that's a little bit of a hassle and might make debugging the start of an app more difficult. So I'm still looking for an actual solution.
I've found the answer when I tried to look for a solution to another problem that randomly popped up out of nowhere.
Androidstudio wouldnt load any previews and put warnings in my layouts, because
One or more layouts are missing the layout_width or layout_height attributes.
One solution suggested in
the answer I found for that problem
was to delete all files in
C:\Users\UserName.AndroidStudio3.2\system\caches
Thats what I did and it solved both problems. Guess the developers have some fixing to do.

Android application doesn't appear on recent apps list

i'm deploying an android application (Android 4.0.3) and when I press the home screen the application doesn't stay on the recent apps list. I've noticed that when I restart the application, it starts on the last screen i've navigated before press the home button. Anyone can help? Here is me Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/logo_home"
android:allowBackup="true">
<activity
android:name="com.test.activity.CommunicatorActivity"
android:launchMode="singleTop"
android:label="" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.test.activity.InputActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
<activity android:name="com.test.activity.SettingsActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
<activity android:name="com.test.activity.OutputActivity"
android:windowSoftInputMode="adjustPan|stateHidden">
</activity>
</application>
</manifest>
I'm going to go out on a limb and suggest that this is your problem:
android:label=""
In your root activity CommunicatorActivity you've set the label to be an empty string. This label is used to identify your app in the list of available apps and because it is empty, this may be causing it not to show up in the list of recent apps.
Remove android:excludeFromRecents="true" from your manifest
You should use
android:label="your app_name"
2 things
Ok, there isn't something obvious in your manifest that should prevent it from appearing in your recents list.
1. Wrong identification
It's not always straight forward to tell which task contains your activity, using the GUI.
One of the possibilities is that an activity from some other app is on top of your task making you believe that your activity isn't there. Since, clearly it resumes to the last screen.
I suggest you to remove the single top temporarily and check the same.
2. Launcher modification
Has the launcher you use the standard launcher? Has the launcher or some other app modified the presentation or behavior of the recents screen (unlikely but worth a check)
For this, I suggest using a stock launcher or try the same app on a different phone or an emulator.
What would help is steps you followed and some screen shots of recents
screen and also of your app
I had the same problem.
The reason is that I had set android:label="" in manifest.xml.
I hadn't set android:launchMode="singleTop".
I declared on purpose android:label="" because I didn't find any better way to remove the title of the action bar from my main activity.
I turned android:label="app_name" again and everything now is OK; the app appears again in recent app list when pressing the home screen and doesn't start on the last navigated screen when restarting it.

Android Live Wallpaper settings button not sending me to settings

So I've managed to get the settings button to appear while in the preview for my live wallpaper. The only issue I'm having is that it's not shooting me to my preference activity. (I've logged it and I never enter the activity).
I have a feeling I must have made a mistake in the XML somewhere... But I cant seem to spot it.
Here's my wallpaper.xml
<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="#drawable/icon"
android:description="#string/wallpaper_description"
android:settingsActivity="com.company.app.package.LiveWallpaperPrefs">
</wallpaper>
Here's the relevant snippet from my manifest.
<service
android:name="com.company.app.package.LiveWallpaperService"
android:enabled="true"
android:icon="#drawable/icon"
android:label="app"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter android:priority="1" >
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/wallpaper" />
</service>
<activity android:name="com.company.app.package.LiveWallpaperPrefs"/>
Anybody know why It's not sending me to my LiveWallpaperPrefs when I press settings? It's actually currently giving me an error "Unfortunately, Live Wallpaper Picker has stopped."
Thanks!
Actually figured it out... I wasn't giving the system permission to enter that settings portion of my app from outside of my app... Here's what fixed my code.
In the manifest (replacing the old LiveWallpaperPrefs)
<activity android:name="com.company.app.package.LiveWallpaperPrefs">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
You could export the LiveWallpaperPrefs like this:
<activity
android:name="com.company.app.package.LiveWallpaperPrefs"
android:exported="true" />
I realize this question is a bit old, but I was having a similar problem. None of the suggestions I found online seemed to be working. No matter what I did, the settings would not display when you tapped the button.
After wasting about 3 hours, I realized that it WAS working, but for some reason I had to completely REMOVE the app from the device and re-install it fresh.
Usually, cleaning the project and re-uploading it to the device actually changes the app. But for some reason the change would not take effect until the app was removed and re-installed.
Hope this helps someone in the future!

Marmalade SDK Widget

I'm using Marmalade SDK and I want to create an app widget. I wrote this in pure Android and now I have a problem: how to attach it to my Marmalade project? I have access to AndroidManifest.xml and there I must add a receiver section but I don't now how to attach my classes and resources to Marmalade.
Edit:
Thanks for your answer Max.
I added
android-manifest=AndroidManifest.xml
android-external-res=android-external-res
android-external-jars="libs/Widget.jar"
to my .mkb file
and this
<receiver android:name="WidgetProvider" android:label="#string/widget1name">
<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>
to my AndroidManifest.xml
Now, when I start my application I haven't errors but my widget is not show on widget list.
Any ideas? Should I also use this?
android-custom-activity
android-extra-application-manifest
And how should I use it?
Edit:
Ok, I found it, section receiver sholudn't be in activity but in application. But next problem is a file R.java from my widget. Marmalade application doesn't see it. Where I have to put it? When I start my widget I get exception:
android.widget.RemoteViews$ActionException: can't find view: 0x...
You need configuration options:
android-external-jars
android-external-res
android-custom-activity
android-manifest
android-extra-application-manifest
http://developer.roolez.com/marmaladesdk/deploy/deploymenttoolsettings/configurationsettings/androidconfigurationsettings.html

No Launcher activity found! in a widget

Good evening.
I've seen that there are people with questions similar to this but I suppose mine is a little different since I haven't found a solution yet.
I've developed a basic widget that displays the battery percentage, and today, two people told me that they can't add my widget to their home screen because it doesn't appear neither in the widget list, neither in the installed applications list. They had to uninstall it from the Android Market.
I'm not sure if this is a bug on their AppWidgetPicker.apk or a bug in my Manifest since my widgets works in most devices. Feel free to search for "henrique rocha" in the Market and install my "Battery Widget" to see if you have the same problem.
In Eclipse I'm getting the following errors:
No Launcher activity found!
The launch will only sync the application package on the device!
I don't know if that might be the problem that causes the widget to not get listed in the widgets list.
Since I don't have an activity, neither a configuration activity and adding both action.MAIN and category.LAUNCHER to my intent-filter tag inside my receiver tag didn't solve the problem, I'm asking for your help.
Here is my full of Manifest if it helps.
<uses-sdk android:minSdkVersion="3" />
<application android:icon="#drawable/battery" android:label="#string/app_name">
<receiver android:name="BatteryAppWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="#xml/appwidget_info" />
</receiver>
<!-- Service to maintain widget alive -->
<service android:name="BatteryService" />
</application>
And here is my appwidget_info.xml:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="72dip"
android:minHeight="72dip"
android:updatePeriodMillis="0"
android:initialLayout="#layout/main"
>
</appwidget-provider>
Well, you're right that since it is a widget you can't launch it from Eclipse: there is no Activity with the Launcher intent filter.
Include your entire Manifest so we can be sure you aren't leaving anything else out The AppWidget provider list should include any receivers that handle the AppWidgetManager.ACTION_APPWIDGET_UPDATE Intent, which yours does, BUT also has the AppWidgetProviderInfo XML metadata. If you have that it should work reliably on every handset that isn't somehow borked. I'd check if the folks reporting that it doesn't work are using alternative widget pickers.

Categories

Resources