2013-02-04 34 views
0

我想一个字符串发送到活动:发送字符串转换活动

public class MyHttpClientUsage { 

    public MyHttpClientUsage(){} 

    public void getInfoAbout() throws HttpException{ 

    RequestParams params = new RequestParams(); 
    params.put("a", "Static"); 
    params.put("content", "47"); 

    MyHttpClient.get("", params, new AsyncHttpResponseHandler(){ 
     @Override 
     public void onSuccess(String response) { 
     System.out.println(response); 
     //How can I send this response 
     } 

    }); 
    } 
} 

因为get()方法是静态的,我不能使用的意图,所以我不能实例的上下文或者在MyHttpClient东西。

回答

1
Bundle basket2 = new Bundle(); 
    basket2.putInt("ID", 3); 
      Intent yourIntent = new Intent("YourActivity"); 
      yourIntent.putExtras(basket2); 
      startActivity(YourIntent); 
+0

你确定,他要送来自活动的字符串? – SVS

+0

我发送的不是来自活动 – Valeriy

0

在德下一个活动尝试......

在第一个活动

inputName = (EditText) findViewById(R.id.name); 
     Button btnNextScreen = (Button) findViewById(R.id.btnNextScreen); 

     //Listening to button event 
     btnNextScreen.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View arg0) { 
       //Starting a new Intent 
       Intent nextScreen = new Intent(getApplicationContext(), SecondScreenActivity.class); 

       //Sending data to another Activity 
       nextScreen.putExtra("name", inputName.getText().toString()); 

       Log.e("n", inputName.getText()); 

       startActivity(nextScreen); 

      } 
     }); 

Intent i = getIntent(); 
     // Receiving the Data 
     String name = i.getStringExtra("name"); 
     Log.e("Second Screen", name); 

     // Displaying Received data 
     txtName.setText(name); 
相关问题