2013-02-04 74 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); 
相關問題