Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get to another application on click of a widget
    primarykey
    data
    text
    <p>I want to get to another application when I click my <code>widget</code>. It doesn't seem to be working. Please tell me where I am going wrong. Here's my code so far. </p> <pre><code>public class MyWidgetProvider extends AppWidgetProvider { public String team1name; public String team2name; public String team1score; public String team2score; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager,int[] appWidgetIds) { super.onUpdate(context, appWidgetManager, appWidgetIds); Log.i(MyWidgetProvider.class.toString(), "Onupdate called for " + this); RemoteViews remoteViews = new RemoteViews(context.getPackageName (), R.layout.widget_layout); Intent in = new Intent(Intent.ACTION_MAIN); PackageManager packageManager = context.getPackageManager(); in = packageManager.getLaunchIntentForPackage("com.playup.android.adapters"); in.addCategory(Intent.CATEGORY_LAUNCHER); PendingIntent pendingIntent2 = PendingIntent.getActivity(context,0 /* no requestCode */, in, 0 /* no flags */); remoteViews.setOnClickPendingIntent(R.id.layout, pendingIntent2); ComponentName thisWidget = new ComponentName(context, MyWidgetProvider.class); AppWidgetManager manager = AppWidgetManager.getInstance(context); manager.updateAppWidget(thisWidget, remoteViews); } public void onReceive(Context context, Intent intent){ Bundle extras = intent.getExtras(); if (extras == null) { return; } team1name = extras.getString("team1name"); team2name = extras.getString("team2name"); team1score = extras.getString("team1score"); team2score = extras.getString("team2score"); RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout); remoteViews.setTextViewText(R.id.team1name, team1name); remoteViews.setTextViewText(R.id.team2name, team2name); remoteViews.setTextViewText(R.id.team1score, team1score); remoteViews.setTextViewText(R.id.team2score, team2score); ComponentName cn = new ComponentName(context, MyWidgetProvider.class); AppWidgetManager.getInstance(context).updateAppWidget(cn, remoteViews); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload