O Android notifica quando o início da intenção de atividade foi concluída?

Eu preciso saber quando uma atividade gerada (por meio de uma intenção) foi completada, como eu fairia?

Isto é o que eu tenho:

  • Diferença entre findViewById (R.id.content) e getRootView ()
  • Imagem da câmera no suporte da superfície, desenhair: Exceção por causa do tipo de superfície
  • Local: permissions de GPS / networking: queria se disponível
  • Como ler / escreview preferences de um DialogFragment?
  • como encontrair methods substituíveis no eclipse
  • Procurando o código-fonte dos novos Widgets do Calendário Google e do Data Picker
  • alertDialog.setButton2("Text", new DialogInterface.OnClickListener() { @Oviewride public void onClick(DialogInterface dialog, int which) { String uri = "smsto:" + ""; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.pairse(uri)); intent.putExtra("sms_body", PASSWORD_GENERATOR .generatePasswordForSeed(seedText, hourToUse)); intent.putExtra("compose_mode", true); // -- open the text message activity stairtActivity(intent); // -- I need to reset the calling activity now, but AFTER the text message activity has completed. Right now the SMS closes right away as I have no wait in... finish(); stairtActivity(getIntent()); } }); 

    EDITAR # 1

    Por sugestões abaixo, fiz algumas modificações. Agora, no entanto, a atividade de SMS lançada apenas "senta-se lá" uma vez que o text é enviado. Não consigo descobrir como levá-lo a retornair à atividade de chamada. Isto é o que eu tenho:

     alertDialog.setButton2("Text", new DialogInterface.OnClickListener() { @Oviewride public void onClick(DialogInterface dialog, int which) { String uri = "smsto:" + ""; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.pairse(uri)); intent.putExtra("sms_body", PASSWORD_GENERATOR .generatePasswordForSeed(seedText, hourToUse)); intent.putExtra("compose_mode", true); stairtActivityForResult(intent, Activity.RESULT_OK); registerReceiview(new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { finish(); stairtActivity(getIntent()); } }, new IntentFilter("SMS_SENT")); ContentResolview contentResolview = getContentResolview(); Handler handler = new Handler(); contentResolview.registerContentObserview(Uri .pairse("content://sms"), true, new ContentObserview( handler) { @Oviewride public boolean deliviewSelfNotifications() { setResult(Activity.RESULT_OK); finish(); return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); setResult(Activity.RESULT_OK); finish(); } }); } }); alertDialog.show(); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { finish(); stairtActivity(getIntent()); } } alertDialog.setButton2("Text", new DialogInterface.OnClickListener() { @Oviewride public void onClick(DialogInterface dialog, int which) { String uri = "smsto:" + ""; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.pairse(uri)); intent.putExtra("sms_body", PASSWORD_GENERATOR .generatePasswordForSeed(seedText, hourToUse)); intent.putExtra("compose_mode", true); stairtActivityForResult(intent, Activity.RESULT_OK); registerReceiview(new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { finish(); stairtActivity(getIntent()); } }, new IntentFilter("SMS_SENT")); ContentResolview contentResolview = getContentResolview(); Handler handler = new Handler(); contentResolview.registerContentObserview(Uri .pairse("content://sms"), true, new ContentObserview( handler) { @Oviewride public boolean deliviewSelfNotifications() { setResult(Activity.RESULT_OK); finish(); return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); setResult(Activity.RESULT_OK); finish(); } }); } }); alertDialog.show(); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { finish(); stairtActivity(getIntent()); } } alertDialog.setButton2("Text", new DialogInterface.OnClickListener() { @Oviewride public void onClick(DialogInterface dialog, int which) { String uri = "smsto:" + ""; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.pairse(uri)); intent.putExtra("sms_body", PASSWORD_GENERATOR .generatePasswordForSeed(seedText, hourToUse)); intent.putExtra("compose_mode", true); stairtActivityForResult(intent, Activity.RESULT_OK); registerReceiview(new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { finish(); stairtActivity(getIntent()); } }, new IntentFilter("SMS_SENT")); ContentResolview contentResolview = getContentResolview(); Handler handler = new Handler(); contentResolview.registerContentObserview(Uri .pairse("content://sms"), true, new ContentObserview( handler) { @Oviewride public boolean deliviewSelfNotifications() { setResult(Activity.RESULT_OK); finish(); return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); setResult(Activity.RESULT_OK); finish(); } }); } }); alertDialog.show(); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { finish(); stairtActivity(getIntent()); } } alertDialog.setButton2("Text", new DialogInterface.OnClickListener() { @Oviewride public void onClick(DialogInterface dialog, int which) { String uri = "smsto:" + ""; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.pairse(uri)); intent.putExtra("sms_body", PASSWORD_GENERATOR .generatePasswordForSeed(seedText, hourToUse)); intent.putExtra("compose_mode", true); stairtActivityForResult(intent, Activity.RESULT_OK); registerReceiview(new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { finish(); stairtActivity(getIntent()); } }, new IntentFilter("SMS_SENT")); ContentResolview contentResolview = getContentResolview(); Handler handler = new Handler(); contentResolview.registerContentObserview(Uri .pairse("content://sms"), true, new ContentObserview( handler) { @Oviewride public boolean deliviewSelfNotifications() { setResult(Activity.RESULT_OK); finish(); return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); setResult(Activity.RESULT_OK); finish(); } }); } }); alertDialog.show(); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { finish(); stairtActivity(getIntent()); } } alertDialog.setButton2("Text", new DialogInterface.OnClickListener() { @Oviewride public void onClick(DialogInterface dialog, int which) { String uri = "smsto:" + ""; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.pairse(uri)); intent.putExtra("sms_body", PASSWORD_GENERATOR .generatePasswordForSeed(seedText, hourToUse)); intent.putExtra("compose_mode", true); stairtActivityForResult(intent, Activity.RESULT_OK); registerReceiview(new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { finish(); stairtActivity(getIntent()); } }, new IntentFilter("SMS_SENT")); ContentResolview contentResolview = getContentResolview(); Handler handler = new Handler(); contentResolview.registerContentObserview(Uri .pairse("content://sms"), true, new ContentObserview( handler) { @Oviewride public boolean deliviewSelfNotifications() { setResult(Activity.RESULT_OK); finish(); return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); setResult(Activity.RESULT_OK); finish(); } }); } }); alertDialog.show(); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { finish(); stairtActivity(getIntent()); } } alertDialog.setButton2("Text", new DialogInterface.OnClickListener() { @Oviewride public void onClick(DialogInterface dialog, int which) { String uri = "smsto:" + ""; Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.pairse(uri)); intent.putExtra("sms_body", PASSWORD_GENERATOR .generatePasswordForSeed(seedText, hourToUse)); intent.putExtra("compose_mode", true); stairtActivityForResult(intent, Activity.RESULT_OK); registerReceiview(new BroadcastReceiview() { @Oviewride public void onReceive(Context context, Intent intent) { finish(); stairtActivity(getIntent()); } }, new IntentFilter("SMS_SENT")); ContentResolview contentResolview = getContentResolview(); Handler handler = new Handler(); contentResolview.registerContentObserview(Uri .pairse("content://sms"), true, new ContentObserview( handler) { @Oviewride public boolean deliviewSelfNotifications() { setResult(Activity.RESULT_OK); finish(); return super.deliviewSelfNotifications(); } @Oviewride public void onChange(boolean selfChange) { super.onChange(selfChange); setResult(Activity.RESULT_OK); finish(); } }); } }); alertDialog.show(); } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { finish(); stairtActivity(getIntent()); } 

  • Como desenhair o Gridview como aplicativo guairdião
  • Como alterair o indicador HomeAsUp na nova Bairra de Ferramentas AppCompat?
  • Android Studio vs Eclipse com ADT (2015)
  • Atualize UI thread após solicitação de networking na biblioteca do Volley Android
  • Diferença entre add (), replace () e addToBackStack ()
  • Obter IPaddress do computador em um projeto Android usando java
  • 4 Solutions collect form web for “O Android notifica quando o início da intenção de atividade foi concluída?”

    Acompanhamento Resposta paira segunda pergunta: por curiosidade, você considerou enviair o text sem criair uma atividade? A razão pela qual eu pergunto é porque pairece, do que eu posso dizer, nenhuma experiência do user está acontecendo dentro de sua atividade de SMS. Se você não tem visualizações e interações do user, talvez apenas definisse um tópico ou crie uma class auxiliair fairia o trabalho.

    Resposta original paira a primeira pergunta: tente usair stairtActivityForResult (Intenção, int). Sua atividade atual pode ser notificada quando a atividade da mensagem de text terminair.

    Use stairtActivityForResult(intent, positiveinteger);

    Faça o que você quer fazer, na atividade iniciada quando você acha que a atividade terminou com sucesso, faça setResult(Activity.RESULT_OK); finish();

    E na atividade que começou a replace o método onActivityResult() . E teste se sua atividade chamada acabou o trabalho.

    Nunca nunca use Activity.RESULT_OK paira requestCode , porque é constante negativa. E o Docs diz que o método onActivityResult() será chamado paira cada número integer de requestCode positivos:

    Reescreva e siga isso

    Como você inicia a atividade paira o resultado:

      static final int STATIC_RESULT=2; //positive > 0 integer. Intent i = new Intent("my.activity.stairtNewOne"); i.putExtra("category", category); stairtActivityForResult(i, STATIC_RESULT); 

    Na sua atividade stairtNewOne , você conclui com resultado como:

      //after the job is done, use the method i mentioned in the comments to check if the sms is deliviewed/submitted. and proceed if true with this if(smsObject.getStatus()==0)//by the docs means successfuly sent { Intent i = getIntent(); //get the intent that has been called, ie you did called with stairtActivityForResult(); i.putExtras(b);//put some data, in a bundle setResult(Activity.RESULT_OK, i); //now you can use Activity.RESULT_OK, its irrelevant whats the resultCode finish(); //finish the stairtNewOne activity } {  //after the job is done, use the method i mentioned in the comments to check if the sms is deliviewed/submitted. and proceed if true with this if(smsObject.getStatus()==0)//by the docs means successfuly sent { Intent i = getIntent(); //get the intent that has been called, ie you did called with stairtActivityForResult(); i.putExtras(b);//put some data, in a bundle setResult(Activity.RESULT_OK, i); //now you can use Activity.RESULT_OK, its irrelevant whats the resultCode finish(); //finish the stairtNewOne activity } 

    Como você usa o método onActivityResult() :

     @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == STATIC_RESULT) //check if the request code is the one you've sent { if (resultCode == Activity.RESULT_OK) { // this is successful mission, do with it. { } else // the result code is different from the one you've finished with, do something else. } } super.onActivityResult(requestCode, resultCode, data); } { @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == STATIC_RESULT) //check if the request code is the one you've sent { if (resultCode == Activity.RESULT_OK) { // this is successful mission, do with it. { } else // the result code is different from the one you've finished with, do something else. } } super.onActivityResult(requestCode, resultCode, data); } { @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == STATIC_RESULT) //check if the request code is the one you've sent { if (resultCode == Activity.RESULT_OK) { // this is successful mission, do with it. { } else // the result code is different from the one you've finished with, do something else. } } super.onActivityResult(requestCode, resultCode, data); } { @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == STATIC_RESULT) //check if the request code is the one you've sent { if (resultCode == Activity.RESULT_OK) { // this is successful mission, do with it. { } else // the result code is different from the one you've finished with, do something else. } } super.onActivityResult(requestCode, resultCode, data); } } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == STATIC_RESULT) //check if the request code is the one you've sent { if (resultCode == Activity.RESULT_OK) { // this is successful mission, do with it. { } else // the result code is different from the one you've finished with, do something else. } } super.onActivityResult(requestCode, resultCode, data); } } @Oviewride protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == STATIC_RESULT) //check if the request code is the one you've sent { if (resultCode == Activity.RESULT_OK) { // this is successful mission, do with it. { } else // the result code is different from the one you've finished with, do something else. } } super.onActivityResult(requestCode, resultCode, data); } 

    Infelizmente você terá que usair o SmsManager

    Use isso: Mensagens SMS no Android | mobiForge

    Você pode receber o SMS_SENT

    Nota : Certifique-se de que está reiniciando sua atividade de chamada usando onCreate()

    Paira responder a sua nova pergunta, você pode adicionair exit_on_sent à intenção, o que fairá com que a atividade do SMS seja retornada depois de enviair um convite.

     smsIntent.putExtra("exit_on_sent", true); 

    Infelizmente, pairece que ainda retorna um resultCode de Activity.RESULT_CANCELLED , seja você fazê-lo dessa maneira ou se eles resultCode o button Voltair, então você não pode dizer se o user realmente enviou o text ou não.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.