Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>know which button is clicked follow these Steps:</p> <p><strong>step 1:</strong> Register two reciver for btnNext and btnPrev</p> <pre><code> &lt;intent-filter &gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;action android:name="com.app.example.MyWidget.ACTION_WIDGET_CLICK_NEXT"/&gt; &lt;action android:name="com.app.example.MyWidget.ACTION_WIDGET_CLICK_PREV"/&gt; &lt;/intent-filter&gt; </code></pre> <p><strong>step 2:</strong> for btnNext and btnPrev action strings:</p> <pre><code>public class MyWidget extends AppWidgetProvider { public static String ACTION_WIDGET_CLICK_NEXT = "Action_nextbtn"; public static String ACTION_WIDGET_CLICK_PREV = "Action_prevbtn"; } </code></pre> <p><strong>step 3:</strong> In onReceive</p> <pre><code>@Override public void onReceive(Context paramContext, Intent paramIntent) { String str = paramIntent.getAction(); if (paramIntent.getAction().equals(ACTION_WIDGET_CLICK_NEXT)) { updateWidgetState(paramContext, str); } if (paramIntent.getAction().equals(ACTION_WIDGET_CLICK_PREV)) { updateWidgetState(paramContext, str); } } </code></pre> <p><strong>step 4:</strong> Make a method for update widget states:</p> <pre><code>static void updateWidgetState(Context paramContext, String paramString) { RemoteViews localRemoteViews = buildUpdate(paramContext, paramString); ComponentName localComponentName = new ComponentName(paramContext, MyWidget.class); AppWidgetManager.getInstance(paramContext).updateAppWidget(localComponentName, localRemoteViews); } </code></pre> <p><strong>Step 5:</strong></p> <pre><code>private static RemoteViews buildUpdate(Context paramContext, String paramString) { rview = new RemoteViews(paramContext.getPackageName(), R.layout.widget_layout); Intent activebtnnext = new Intent(paramContext, MyWidget.class); active.setAction(ACTION_WIDGET_CLICK_NEXT); PendingIntent configPendingIntentnext = PendingIntent.getBroadcast(paramContext, 0, activebtnnext , 0); rmViews.setOnClickPendingIntent(R.id.btnNext, configPendingIntentnext); Intent activeprevbtn = new Intent(paramContext, MyWidget.class); active.setAction(ACTION_WIDGET_CLICK_PREV); PendingIntent configPendingIntentprev = PendingIntent.getBroadcast(paramContext, 0, activeprevbtn , 0); rmViews.setOnClickPendingIntent(R.id.btnprev, configPendingIntentprev); if(parmString.equals(ACTION_WIDGET_CLICK_NEXT)) { // } if(parmString.equals(ACTION_WIDGET_CLICK_PREV)) { // } return rview; } </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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