Has anyone experienced their app widget not being listed in the ICS app drawer?
Originally I started this app for FroYo and below, which supports the app widget just fine. Along came Gingerbread and Honeycomb, those work too.
The widget appears in the list in the emulator if I open up the "Widget Preview" app, however when you just open the drawer it isn't listed with the others. It does appear on Honeycomb. I don't (and others haven't also) see it on my Galaxy Nexus anywhere either.
I've tried rebooting as I've seen that solving the problem for some people after initial installation. Also I do have a main activity with the action.MAIN/category.LAUNCHER intent filter since I have app activities, this isn't a widget only type of project.
I'll post some snippets below, let me know if more is needed. My minSdkVersion is at 7 and targetSdkVersion at 15, project properties also has the target checked at 4.0.3. The installLocation attribute is set to auto.
AndroidManifest.xml:
<receiver android:name=".AppWidget" android:label="#string/one_cell_widget_label">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<intent-filter>
<action android:name="com.frankcalise.h2droid.FORCE_WIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="#xml/one_cell_widget_settings" />
</receiver>
one_cell_widget_settings.xml:
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:initialLayout="#layout/one_cell_widget"
android:minWidth="#dimen/one_cell_widget"
android:maxHeight="#dimen/one_cell_widget"
android:updatePeriodMillis="0" >
</appwidget-provider>
one_cell_widget.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/widget_background"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/widget_margin"
android:background="#drawable/widget_background">
<TextView
android:id="#+id/widget_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/widget_amount_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/default_widget_amount"
android:textSize="12sp"
android:textColor="#color/amount_color" />
<TextView
android:id="#+id/widget_percent_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/default_widget_percent" />
</LinearLayout>
and then obviously I implemented the class in AppWidget.java
public class AppWidget extends AppWidgetProvider
UPDATE:
An important logcat message I found earlier today which helped me solve the issue:
06-01 14:41:31.606: E/AppsCustomizePagedView(199): Widget ComponentInfo{com.frankcalise.h2droid/com.frankcalise.h2droid.AppWidget} has invalid dimensions (108, 0)
I found the issue. My appwidget-provider element has a typo in one of the attributes, it should say "minHeight", not "maxHeight".
What lead me to finding this was finding an error output in logcat from the launcher. It mentioned my widget had invalid dimensions (therefore it didn't add it to the list of widgets). So then I started checking all the dimension attributes related to my widget.
Related
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!
I'm recently been trying to get R.JAVA to generate with no avail. I've tried the following
1. Adding spaces to the manifest file
2. Project--> Clean
So my last guess is that there is some error in my xml files that I/eclipse haven't been able to see. So I was hoping to have a second pair of eyes that might be able to check my xml files for review. There's only three and they should be pretty basic(I'm following a intro to android book).
Manifest File
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.activites"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activity2"
android:label="Activity 2" >
<intent-filter>
<action android:name="com.example.ACTIVITY2" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
Activity2.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is Activity 2!" />
</RelativeLayout>
Again thanks to all of you that have taken time out of your busy day/night to help out a beginner like myself. Also if there's any suggestion other than errors in the xml feel free to bring them up.
As requested here are the problems appear in windows-> show view -> problems
R cannot be resolved to a variable
R cannot be resolved to a variable
R cannot be resolved to a variable
Tag is not that obvious it is used to show debug information in catlog with the following lines of code.
public class MainActivity extends Activity {
String tag = "Events";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
Log.d(tag, "In the onCreate() event");
}
In eclipse you can check the Problems view(windows-->show view-->Problems) or/and the Console view to help locate errors in Xml efficiently. If you remain need help you may want to post these errors to us
I get following error when I compile your code:
res\layout\Activity2.xml: Invalid file name: must contain only
[a-z0-9_.]
So remove capital A and rename "Activity2.xml" to "activity2.xml"
Also, if this doesn't help, try this:-
Rename your package name to some other. Clean. Restart Eclipse. Rename package back to the previous one. Again clean. Restart Eclipse.
check your imports. is import android.R anywhere there? if so, remove it. if you're indeed following some android tutorial in a book and it instructed you to organize or manage imports with Ctrl+shift+O or otherwise, that will cause that to pop up.
tag should be a String variable. What is it defined as? You should probably hard-code it there, unless you are using it as a global variable for your application.
http://developer.android.com/reference/android/util/Log.html#d%28java.lang.String,%20java.lang.String%29
EDIT: R cannot be resolved - Android error has a lot of different answers, try reading through those. If the first one doesn't solve your problem, another one might.
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!
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I get device ID for Admob
My activity has a ListView and I've put an ad at the bottom. When I run the app on the emulator, I see the test ad. When I run on my phone, I get an actual ad. I want to test on my phone and not get real ads.
I followed the instructions on the AdMob site about looking in logcat for a message stating how to manually add the device ID to the AdRequest. The problem is this message would never appear in logcat. This is a RAZR running 4.1. In an SO post, answered by Aracem, I read that the encoded string is available in the Developer Options preference panel, and I found it. When I read the guide for this command, the format of the device ID was alphanumeric (e.g. "E83D20734F72FB3108F104ABC0FFC738"), but the value in my phone contains letters, numbers, and dashes (e.g. "MQKF-RB61-BBKS-E").
I've added the encoded device ID into the XML googleads:testDevices and I've also manually added an AdRequest into my onCreate and use addTestDevice with this string. Neither work.
One thing that I've noticed is the namespace that works is googleads, not ads as shown in the examples. When I use ads, I get prefix errors in the XML. I'm guessing with the switch from 4.x to 6.1, the namespace changed.
I can make this happen with the minimal project where onCreate does nothing more than call super and setContentView.
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/list"
android:layout_above="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
googleads:adSize="BANNER"
googleads:adUnitId="#string/admob_id"
googleads:loadAdOnCreate="true"
googleads:testDevices="TEST_EMULATOR, MQKF-RB61-BBKS-E" />
Manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="16" />
<application android:label="#string/app_name" >
<activity
android:name="mainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>
In the Logcat, you will find the device ID. You will see something like
To get test ads on this device, call adRequest.addTestDevice("**")
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.