将JsonResponse传递给IntentService

时间:2017-03-30 12:25:08

标签: java android android-intent sharedpreferences httpresponse

我有MainActivity我可以得到很好的反应:

 JSONObject responseVal = responseObj.getJSONObject("data");
                message = responseVal.getString("id");
                Log.i(TAG, "onResponse: " + message);

我有IntentService并希望将message值传递给它。

我尝试使用SharedPreferencesintentPutExtra,但它不起作用。

最好的方法是什么?

2 个答案:

答案 0 :(得分:0)

如果您想将该消息存储到应用程序中,而不是用户共享优先使用其他方式使用getIntent.getextra()Intent i=new Intent(this,yourclass.class); i.putExtra("demo",message); 方法。

单击

上的

yourclass.class

String mes=getIntent().getStringExtra("demo");

    textsize    2147483647
    language    us_english
    dateformat  mdy
    datefirst   7
    lock_timeout    -1
    quoted_identifier   SET
    arithabort  SET
    ansi_null_dflt_on   SET
    ansi_warnings   SET
    ansi_padding    SET
    ansi_nulls  SET
    concat_null_yields_null SET
    isolation level read committed

答案 1 :(得分:0)

  1. 要将Truncation发送到message,请尝试以下操作:

    IntentService
  2. 要接收Intent intent = new Intent(MainActivity.this, YourIntentService.class); intent.putExtra("message", message); startService(intent); 中的message,请尝试以下操作:

    IntentService