0

I have a widget, but im not sure how to open a app from it by clicking on it. I have set an ID on the layout, so there is a setOnClickPendingIntent listener on the layout. As currently, im not sure what im doing, but this is my code so far..

        //Intent to open app on click
    Intent intent = new Intent(context, AddPersonActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0, null);
    widgetview.setOnClickPendingIntent(R.id.mainwidget, pendingIntent);
    widgetview.setOnClickPendingIntent(R.id.widget_logo, pendingIntent);

My manifest is currently like this

        <receiver
        android:name=".MyWidgetProvider"
        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_info" />
    </receiver>

I have no idea, please help.

Codebox
  • 97
  • 1
  • 3
  • 11

1 Answers1

0
Intent active = new Intent(context, ExampleProvider.class);
    active.setAction(ACTION_WIDGET_REFRESH);
    PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0);
    widgetview.setOnClickPendingIntent(R.id.mainwidget, actionPendingIntent);
Biswajit
  • 2,434
  • 2
  • 28
  • 35