2010-12-10 25 views
0

我在写一个应用程序,其中有两个活动和一个服务。 现在我想通过主要活动从服务中获得一些值,并将该值发送到第二个活动。基本上我想从服务中获取一个字符串数组,并将该数组发送到下一个活动。我知道我可以通过Intent.putextra()的帮助将该sring数组发送到下一个活动。 但我不知道如何从后台运行的服务中获取字符串数组。请帮我.. Thankx ..如何从服务中获取值?

回答

1
public class ResponseReceiver extends BroadcastReceiver { 
    public static final String ACTION_RESP = "com.mamlambo.intent.action.MESSAGE_PROCESSED"; 

    @Override 
    public void onReceive(Context context, Intent intent) { 

     // Update UI, new "message" processed by SimpleIntentService 

     String text = (String)intent.getStringExtra(Login.PARAM_OUT_MSG); 
    } 
} 
+0

也许应该注明出处材料http://android10.org/index.php/articleswhitepapers/314-android-fundamentals-intentservice-basics – Terrance 2011-12-31 02:31:15