ramya
ramya

Reputation: 368

how to identify an activity opened from widget or how to send any intent to the activity opened from widget

I tried opening the activity from the widget from the below code`

Intent defineIntent = new Intent(ConfigurationActivity.this,EditActivity.class);
            defineIntent.putExtra("from_widget",true);
            PendingIntent pendingIntent1 = PendingIntent.getActivity(ConfigurationActivity.this,0 /* no requestCode */, defineIntent, 0 /* no flags */);
            views.setOnClickPendingIntent(R.id.img_widget, pendingIntent1);

but I don't have idea to identify the activity that is opened from widget.

Upvotes: 2

Views: 84

Answers (1)

Veer
Veer

Reputation: 1383

In the EditActivity's onCreate() method, write this code:

boolean isFromWidget = getIntent().getStringExtra("from_widget",false);

This code will get the value from the previous Activity. "isFromWidget" is true means the activity is opened from widget.

Upvotes: 1

Related Questions