Wednesday 15 February 2012

android show widget on lock screen -


I am unable to show the widget on the lock screen of the Android device, my code:
   

Package com.example.widgetapp; Android Import annotations. Import android.app.PendingIntent; Import android.appwidget.AppWidgetManager; Import android.appwidget.AppWidgetProvider; Import android.content.ActivityNotFoundException; Import android.content.ComponentName; Import android.content.Context; Import android.content.Intent; Import android.net.Uri; Import android.view Windows Manager; Import android.widget.RemoteViews; Import android.widget.Toast; Public Class Main Activity AppWidgetProvider {// Personal Static Final String ACTION_CLICK = "ACTION_CLICK" is extensively; Public Situation on the @SuppressLint ("NewApi") update (Reference Reference, AppWidgetManager appWidgetManager, int [] appWidgetIds) {ComponentName thisWidget = New ComponentName (Reference, MainActivity.class); Int [] allWidgetIds = appWidgetManager.getAppWidgetIds (thisWidget); (Int widgetID: allwidges) {try {// getwindow (). Adflag (window manager. Layout parama.flag_shhh_YHA_loxax); // getWindow () AddFlags (WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); Intent intention = new intent ("android.intent.action.MAIN"); Intent.addCategory ("android.intent.category.LAUNCHER"); Intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK); Intent.setComponent (ComponentName.unflattenFromString ("com.example.rage / com.example.rage.RageActivity")); Intention call = new intent (intention.action_call, Uri. PRSE ("tele:" + 98)); CallIntent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); //remoteViews.setOnClickFillInIntent(widgetId, callIntent); Pending pending vertical positioning = pending.activity (reference, 0, intent, 0); Pending pending vertical 1 = Pending content. Connectivity (context, 0, callincent, 0); RemoteView View = New Remote Power (context.getPackageName (), R. layout.activation_man); // views.setOnClickFillInIntent (widget ID, intent); // views.setOnClickFillInIntent (widgetId, callIntent); // context.startActivity; // context.startActivity (callIntent); Views.setOnClickPendingIntent (R.id.button1, Pending INTent1); Views.setOnClickPendingIntent (R.id.button2, pending pending); AppWidgetManager.updateAppWidget (widgetID, view); } Catch (ActivityNotFoundException e) {Toast.makeText (context.getApplicationContext), "There was a problem loading the application:", toast .LENGTH_SHORT). Show (); }}}}

Try adding: "android: widgetCategory =" home_screen | Keyguard "provider xml

  & lt; appwidget-provider xmlns: android =" http://schemas.android.com/apk/res/android "Android: initialLayout =" @ layout / my_widget_layout "Android: MinHeight =" 40dp "Android: minWidth =" 40dp "Android: resizeMode =" Horizontal | Vertical "Android: widgetCategory =" home_screen | Keyguard "& gt; & lt; / appwidget-provider & gt;    

No comments:

Post a Comment