how to create alertdialog outside of an application?

前端 未结 1 1199
感情败类
感情败类 2021-01-26 05:23

I want to create an alertdialog outside of my application.

AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(Config_ConstantVa         


        
相关标签:
1条回答
  • 2021-01-26 05:58

    I am using the same functionality in my app where i used one activity as a pop up message like below

     @Override
    public void onReceive(Context context, Intent intent) {
    
    
        try {
             Bundle bundle = intent.getExtras();
             String message = bundle.getString("alarm_message");
    
             Intent newIntent = new Intent(context, PopupActivity.class);
             newIntent.putExtra("alarm_message", message);
             newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
             context.startActivity(newIntent);
            } catch (Exception e) { 
             e.printStackTrace();
    
            }
    }
    

    In the Popup Activity design the UI like the dialog box and add this in Android Manifest.xml

     <activity android:name=".PopupActivity"
                 android:theme="@android:style/Theme.Dialog"
                 android:label="@string/label"
                 ></activity>
    

    You can customise the UI based on your specification.Its working perfectly for me. I hope it helps.

    0 讨论(0)
提交回复
热议问题