android - Error adding widget to homescreen -- The Linked Program is no Longer Installed on Your Phone -
i creating android widget , when run widget, after cleaning workspace , deleting previous instance of widget device via application manager, when go add widget device, error "the linked program no longer installed on phone".
before started happening, used error:
10-06 08:58:29.448: d/androidruntime(6994): shutting down vm 10-06 08:58:29.448: w/dalvikvm(6994): threadid=1: thread exiting uncaught exception (group=0x4001d5a0) 10-06 08:58:29.458: e/androidruntime(6994): fatal exception: main 10-06 08:58:29.458: e/androidruntime(6994): java.lang.runtimeexception: unable instantiate receiver com.example.awesomefilebuilderwidget.afbwidget: java.lang.classnotfoundexception: com.example.awesomefilebuilderwidget.afbwidget in loader dalvik.system.pathclassloader[/data/app/com.example.awesomefilebuilderwidget-1.apk] 10-06 08:58:29.458: e/androidruntime(6994): @ android.app.activitythread.handlereceiver(activitythread.java:2012) 10-06 08:58:29.458: e/androidruntime(6994): @ android.app.activitythread.access$2400(activitythread.java:135) 10-06 08:58:29.458: e/androidruntime(6994): @ android.app.activitythread$h.handlemessage(activitythread.java:1101) 10-06 08:58:29.458: e/androidruntime(6994): @ android.os.handler.dispatchmessage(handler.java:99) 10-06 08:58:29.458: e/androidruntime(6994): @ android.os.looper.loop(looper.java:150) 10-06 08:58:29.458: e/androidruntime(6994): @ android.app.activitythread.main(activitythread.java:4333) 10-06 08:58:29.458: e/androidruntime(6994): @ java.lang.reflect.method.invokenative(native method) 10-06 08:58:29.458: e/androidruntime(6994): @ java.lang.reflect.method.invoke(method.java:507) 10-06 08:58:29.458: e/androidruntime(6994): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839) 10-06 08:58:29.458: e/androidruntime(6994): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597) 10-06 08:58:29.458: e/androidruntime(6994): @ dalvik.system.nativestart.main(native method) 10-06 08:58:29.458: e/androidruntime(6994): caused by: java.lang.classnotfoundexception: com.example.awesomefilebuilderwidget.afbwidget in loader dalvik.system.pathclassloader[/data/app/com.example.awesomefilebuilderwidget-1.apk] 10-06 08:58:29.458: e/androidruntime(6994): @ dalvik.system.pathclassloader.findclass(pathclassloader.java:240) 10-06 08:58:29.458: e/androidruntime(6994): @ java.lang.classloader.loadclass(classloader.java:551) 10-06 08:58:29.458: e/androidruntime(6994): @ java.lang.classloader.loadclass(classloader.java:511) 10-06 08:58:29.458: e/androidruntime(6994): @ android.app.activitythread.handlereceiver(activitythread.java:2003) 10-06 08:58:29.458: e/androidruntime(6994): ... 10 more 10-06 08:58:36.535: w/dalvikvm(7066): threadid=1: thread exiting uncaught exception (group=0x4001d5a0)
here manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.awesomefilebuilderwidget" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="18" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <receiver android:name=".afbwidget" android:label="@string/app_name"> <intent-filter> <action android:name="android.appwidget.action.appwidget_update"/> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_stuff"/> </receiver> <activity android:name="com.example.awesomefilebuilder.widgetconfig" android:label="@string/app_name"> <intent-filter> <action android:name="android.appwidget.action.appwidget_configure"/> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="com.example.awesomefilebuilderwidget.afbwidget" android:label="@string/app_name"/> </application> </manifest>
i have 2 classes: afbwidget.java:
import java.util.random; import com.example.awesomefilebuilderwidget.r; import android.appwidget.appwidgetmanager; import android.appwidget.appwidgetprovider; import android.content.context; import android.widget.remoteviews; import android.widget.toast; public class afbwidget extends appwidgetprovider{ @override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { // todo auto-generated method stub super.onupdate(context, appwidgetmanager, appwidgetids); random r = new random(); int randomint = r.nextint(1000000000); string rand = string.valueof(randomint); final int n = appwidgetids.length; (int = 0; < n; i++){ int awid = appwidgetids[i]; remoteviews v = new remoteviews(context.getpackagename(), r.layout.widget); v.settextviewtext(r.id.tvwidgetupdate, rand); appwidgetmanager.updateappwidget(awid, v); } } @override public void ondeleted(context context, int[] appwidgetids) { // todo auto-generated method stub super.ondeleted(context, appwidgetids); toast.maketext(context, "thanks checking out!", toast.length_short).show(); } }
widgetconfig.java:
import android.app.activity; import android.app.pendingintent; import android.appwidget.appwidgetmanager; import android.content.context; import android.content.intent; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.remoteviews; import com.example.awesomefilebuilderwidget.r; public class widgetconfig extends activity implements onclicklistener{ edittext info; appwidgetmanager awm; context c; int awid; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.widgetconfig); button b = (button)findviewbyid(r.id.bwidgetconfig); b.setonclicklistener(this); c = widgetconfig.this; info = (edittext)findviewbyid(r.id.etwidgetconfig); //getting info widget launched activity intent = getintent(); bundle extras = i.getextras(); if (extras != null){ awid = extras.getint(appwidgetmanager.extra_appwidget_id, appwidgetmanager.invalid_appwidget_id ); }else{ finish(); } awm = appwidgetmanager.getinstance(c); } @override public void onclick(view v) { // todo auto-generated method stub string e = info.gettext().tostring(); remoteviews views = new remoteviews(c.getpackagename(), r.layout.widget); views.settextviewtext(r.id.tvconfiginput, e); intent in = new intent(c, widgetconfig.class); pendingintent pi = pendingintent.getactivity(c, 0, in, 0); views.setonclickpendingintent(r.id.bwidgetopen, pi); awm.updateappwidget(awid, views); intent result = new intent(); result.putextra(appwidgetmanager.extra_appwidget_id, awid); setresult(result_ok, result); finish(); } }
i can't figure out how fix error no matter do. what's wrong?
do following modifications in manifest:
remove line:
<category android:name="android.intent.category.launcher" />
your widget configuration acitivity cant launcher acitivity! widget config launched once user selects widget form widget list, , handled andorid os.
if want launcher acitivity has else , wont able add widgets it. widgets can added described, when user clicks widget widget list(where optionally open config)
once cleared, remove:
<activity android:name="com.example.awesomefilebuilderwidget.afbwidget" android:label="@string/app_name"/>
this line makes no sense? declared .afbwidget receiver few lines above, , saying acitivity isnt. ;) extending appwidgetprovider.
also when declaring receiver add full package name this:
<receiver android:name="com.example.awesomefilebuilderwidget.afbwidget" android:label="@string/app_name"> ....
let me know how goes.
Comments
Post a Comment