I have created an activity, that launches a broadcast receiver, The Broadcast receiver launches another activity. The second activity just has a TextView
, I have defined a transparent background for the 2nd activity.
But the activity opens over the 1st activity, and displays black background,and not the 1st activity in the background.
Kindly guide me how can i achieve Alert Dialog like feel in this, As i want to display an alert dialog from Broadcast receiver, so this is the only possible way i found to do this.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent();
intent.setAction("com.myapp.serviceIntent");
sendBroadcast(intent);
Broadcast
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Intent Detected.", Toast.LENGTH_LONG).show();
Intent i= new Intent(context.getApplicationContext(), AlertActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}