Android 如何将值从异步任务发送到另一个新活动?

Android 如何将值从异步任务发送到另一个新活动?,android,android-intent,android-asynctask,google-cloud-platform,Android,Android Intent,Android Asynctask,Google Cloud Platform,我在异步任务中调用convertResponseToString,但是我也有一个按钮,如何获取logo.feature以在新活动中显示输出? 基本上,我想在新的活动中显示消息。有什么建议吗 > 'public String convertResponseToString(BatchAnnotateImagesResponse > response) { > String message = "I FOUND THESE THINGS = :\n\n"; >

我在异步任务中调用convertResponseToString,但是我也有一个按钮,如何获取logo.feature以在新活动中显示输出? 基本上,我想在新的活动中显示消息。有什么建议吗

> 'public String convertResponseToString(BatchAnnotateImagesResponse
> response) {
>         String message = "I FOUND THESE THINGS = :\n\n";
> 
>         List<EntityAnnotation> logos = response.getResponses().get(0).getLogoAnnotations();
>         List<EntityAnnotation> labels = response.getResponses().get(0).getLabelAnnotations();
>         if (logos != null) {
>             for (EntityAnnotation logo : logos) {
>                 String s = logo.getDescription();
>                 EditText logodesc=(EditText)findViewById(R.id.editText);
>                 logodesc.setText(s);
>                 message += String.format(Locale.US, "The score is : %.3f & The logo detected is : %s ",
> logo.getScore(),logo.getDescription());
>                 message += "\n\n";
>             }
>         } else {
>             message += "NOTHING FOUND!\n";
>         }
>         if(labels !=null) {
>             for (EntityAnnotation label : labels) {
>                 message += String.format(Locale.US, "The score is: %.3f & The label detected is : %s ", label.getScore(),
> label.getDescription());
>                 message += "\n";
>             }
>         }else{
>             message += "NOTHING FOUND!";
>         }
>         return message;
> 
>     }
>     public void init()
>     {
>         mbutton=(Button)findViewById(R.id.button);
>         mbutton.setOnClickListener(new View.OnClickListener() {
>             @Override
>             public void onClick(View view) {
>                 Intent i = new Intent(MainActivity.this,Result.class);
>                 i.putExtra("Logo");
>                 startActivity(i);
>             }
>         });
>     }
公共字符串convertResponseToString(批注释图像响应 >(答复){ >String message=“我找到了这些东西=:\n\n”; > >列出logo=response.getResponses().get(0.getlogonations(); >列表标签=response.getResponses().get(0.getLabelNotations(); >如果(徽标!=null){ >用于(实体注释徽标:徽标){ >字符串s=logo.getDescription(); >EditText logodesc=(EditText)findViewById(R.id.EditText); >logodesc.setText; >message+=String.format(Locale.US,“分数为:%.3f&检测到的徽标为:%s”, >logo.getScore(),logo.getDescription(); >消息+=“\n\n”; > } >}其他{ >消息+=“未找到任何内容!\n”; > } >如果(标签!=null){ >用于(EntityAnnotation标签:标签){ >message+=String.format(Locale.US,“分数为:%.3f&检测到的标签为:%s”,label.getScore(), >label.getDescription()); >消息+=“\n”; > } >}其他{ >消息+=“未找到任何内容!”; > } >返回消息; > > } >公共void init() > { >mbutton=(按钮)findviewbyd(R.id.Button); >mbutton.setOnClickListener(新视图.OnClickListener(){ >@覆盖 >公共void onClick(视图){ >意图i=新意图(MainActivity.this,Result.class); >i.putExtra(“标识”); >星触觉(i); > } > }); > } }"


在您的第一个活动中,当您单击按钮时,您可以发送下一个活动的值,如下所示

Intent i = new Intent(MainActivity.this,Result.class);     
i.putExtra("Logo","whatever message you want to sent");                      
startActivity(i);
现在你如何得到这些先前值的值呢?为此,在“结果”活动中获得如下值

Intent data =getIntent();
String message= data.getStringExtra("Logo");