java - Programtically bypass "touch to configure" Android Widget -
i know how bypass "touch configure" on android widget programmatically. once have installed android widget on device says "touch configure" executes class "intelligenwidgetconfig.java". want automatically happen on start of application. can advise me on how approach method or solution might help?
android config class:
public class intelligenwidgetconfig extends activity { private static final string tag = "intelligenwidgetconfig"; public intelligenwidgetconfig() { super(); } public static int getappwidgetid(context context) { sharedpreferences settings = context.getsharedpreferences("intelligen", mode_private); return settings.getint("appwidgetid", 1); } protected void setappwidgetid(int id) { sharedpreferences settings = getsharedpreferences("intelligen", mode_private); sharedpreferences.editor editor = settings.edit(); editor.putint("appwidgetid", id); editor.commit(); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // set result canceled. cause widget host cancel // out of widget placement if press button. setresult(result_canceled); // find widget id intent. intent intent = getintent(); bundle extras = intent.getextras(); if (extras != null) { setappwidgetid(extras.getint(appwidgetmanager.extra_appwidget_id, appwidgetmanager.invalid_appwidget_id)); } // if gave intent without widget id, bail. if (getappwidgetid(this) == appwidgetmanager.invalid_appwidget_id) { finish(); } final context context = intelligenwidgetconfig.this; registerforpushnotification(context); // push widget update appwidgetmanager appwidgetmanager = appwidgetmanager.getinstance(context); remoteviews views = new remoteviews(context.getpackagename(), r.layout.intelligen_widget_layout); appwidgetmanager.updateappwidget(getappwidgetid(this), views); // make sure pass original appwidgetid intent resultvalue = new intent(); resultvalue.putextra(appwidgetmanager.extra_appwidget_id, getappwidgetid(this)); setresult(result_ok, resultvalue); finish(); } private void registerforpushnotification(context ctx) { intent registerintent = new intent("com.google.android.c2dm.intent.register"); registerintent.putextra("app", pendingintent.getbroadcast(ctx, 0, new intent(), 0)); registerintent.putextra("sender", "209845001369"); startservice(registerintent); } private void deregisterfrompushnotification(context ctx) { intent unregisterintent = new intent("com.google.android.c2dm.intent.unregister"); unregisterintent.putextra("app", pendingintent.getbroadcast(ctx, 0, new intent(), 0)); startservice(unregisterintent); } }
androidmanifest.xml (section):
<activity android:name=".intelligenwidgetconfig" android:label="@string/app_name"> <intent-filter> <action android:name="android.appwidget.action.appwidget_configure"/> </intent-filter> </activity>
xml
<?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minwidth="180dp" android:minheight="360dp" android:updateperiodmillis="0" android:initiallayout="@layout/intelligen_widget_layout" android:resizemode="vertical" android:minresizewidth="280dp" android:minresizeheight="70dp" android:configure="za.co.infotech.www.intelligen.intelligenwidgetconfig" android:previewimage="@drawable/preview"> </appwidget-provider>
Comments
Post a Comment