2

알림, Asynctasks 및 브로드 캐스트 Recievers를 다루는 과정 프로젝트를 진행 중입니다. 나는 세 가지 테스트를 가지고있다. 첫 번째 테스트는 스택 추적 오류와 함께 실패한다 :'java.lang.IllegalArgumentException'으로 인해 '계측 실행이 실패했습니다.'를 수정하는 방법

테스트를 완료하지 못했습니다. 이유 : ''java.lang.IllegalArgumentException '으로 인해 계측 실행에 실패했습니다. 자세한 내용은 장치 logcat을 확인하십시오.

Logcat이 큽니다. 내가 무엇을 찾고 있는지 말해 줄 수 있다면 나는 tag : function으로 그것을 좁힐 수있다.

다른 두 테스트는 정상적으로 실행됩니다.

아래의 첫 번째 파일은 Eclipse에서 오류를 표시하지 않습니다.

public class MainActivity extends Activity implements SelectionListener { 

     public static final String TWEET_FILENAME = "tweets.txt"; 
     public static final String[] FRIENDS = { "taylorswift13", "msrebeccablack", 
     "ladygaga" }; 
     public static final String DATA_REFRESHED_ACTION ="course.labs.notificationslab.DATA_REFRESHED"; 

     private static final int NUM_FRIENDS = 3; 
     private static final String URL_LGAGA = "https://d396qusza40orc.cloudfront.net/android%2FLabs%2FUserNotifications%2Fladygaga.txt"; 
     private static final String URL_RBLACK = "https://d396qusza40orc.cloudfront.net/android%2FLabs%2FUserNotifications%2Frebeccablack.txt"; 
     private static final String URL_TSWIFT = "https://d396qusza40orc.cloudfront.net/android%2FLabs%2FUserNotifications%2Ftaylorswift.txt"; 
     private static final String TAG = "Lab-Notifications"; 
     private static final long TWO_MIN = 2 * 60 * 1000; 
     private FragmentManager mFragmentManager; 
     private FriendsFragment mFriendsFragment; 
     private boolean mIsFresh; 
     private BroadcastReceiver mRefreshReceiver; 
     private int mFeedSelected = UNSELECTED; 
     private FeedFragment mFeedFragment; 
     private String[] mRawFeeds = new String[3]; 
     private String[] mProcessedFeeds = new String[3]; 

@Override 
     protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     mFragmentManager = getFragmentManager(); 
     addFriendsFragment(); 
    // The feed is fresh if it was downloaded less than 2 minutes ago 
     mIsFresh = (System.currentTimeMillis() - getFileStreamPath(
      TWEET_FILENAME).lastModified()) < TWO_MIN; 

     ensureData(); 

} 

// Add Friends Fragment to Activity 
     private void addFriendsFragment() { 

     mFriendsFragment = new FriendsFragment(); 
     mFriendsFragment.setArguments(getIntent().getExtras()); 

     FragmentTransaction transaction = mFragmentManager.beginTransaction(); 
     transaction.add(R.id.fragment_container, mFriendsFragment); 

     transaction.commit(); 
} 

// If stored Tweets are not fresh, reload them from network 
// Otherwise, load them from file 
     private void ensureData() { 

    log("In ensureData(), mIsFresh:" + mIsFresh); 

     if (!mIsFresh) { 

     // TODO: 
     // Show a Toast Notification to inform user that 
     // the app is "Downloading Tweets from Network" 
     log ("Issuing Toast Message"); 
     Toast.makeText(getApplicationContext(), "refreshing Tweets",Toast.LENGTH_LONG).show(); 


     // TODO: 
     // Start new AsyncTask to download Tweets from network 
     new DownloaderTask(MainActivity.this).execute(MainActivity.URL_LGAGA,MainActivity.URL_RBLACK,MainActivity.URL_TSWIFT); 





     // Set up a BroadcastReceiver to receive an Intent when download 
     // finishes. 
      mRefreshReceiver = new BroadcastReceiver() { 
      @Override 
      public void onReceive(Context context, Intent intent) { 

       log("BroadcastIntent received in MainActivity"); 

       // TODO:     
       // Check to make sure this is an ordered broadcast 
       // Let sender know that the Intent was received 
       // by setting result code to RESULT_OK 
       sendOrderedBroadcast(new Intent(), null, null, null, RESULT_OK, null, null); 

      } 
     }; 

    } else { 

     loadTweetsFromFile(); 
     parseJSON(); 
     updateFeed(); 

    } 
} 

// Called when new Tweets have been downloaded 
public void setRefreshed(String[] feeds) { 

    mRawFeeds[0] = feeds[0]; 
    mRawFeeds[1] = feeds[1]; 
    mRawFeeds[2] = feeds[2]; 

    parseJSON(); 
    updateFeed(); 
    mIsFresh = true; 

}; 

// Called when a Friend is clicked on 
@Override 
public void onItemSelected(int position) { 

    mFeedSelected = position; 
    mFeedFragment = addFeedFragment(); 

    if (mIsFresh) { 
     updateFeed(); 
    } 
} 

// Calls FeedFragement.update, passing in the 
// the tweets for the currently selected friend 

void updateFeed() { 

    if (null != mFeedFragment) 

     mFeedFragment.update(mProcessedFeeds[mFeedSelected]); 

} 

// Add FeedFragment to Activity 
private FeedFragment addFeedFragment() { 
    FeedFragment feedFragment; 
    feedFragment = new FeedFragment(); 

    FragmentTransaction transaction = mFragmentManager.beginTransaction(); 

    transaction.replace(R.id.fragment_container, feedFragment); 
    transaction.addToBackStack(null); 

    transaction.commit(); 
    mFragmentManager.executePendingTransactions(); 
    return feedFragment; 

} 

// Register the BroadcastReceiver 
@Override 
protected void onResume() { 
    super.onResume(); 

    // TODO: 
    // Register the BroadcastReceiver to receive a 
    // DATA_REFRESHED_ACTION broadcast 
    IntentFilter intentFilter = new IntentFilter(DATA_REFRESHED_ACTION); 
     registerReceiver(mRefreshReceiver, intentFilter); 


} 

@Override 
protected void onPause() { 

    // TODO: 
    // Unregister the BroadcastReceiver 
    unregisterReceiver(mRefreshReceiver); 



    super.onPause(); 

} 

// Convert raw Tweet data (in JSON format) into text for display 

public void parseJSON() { 

    JSONArray[] JSONFeeds = new JSONArray[NUM_FRIENDS]; 

    for (int i = 0; i < NUM_FRIENDS; i++) { 
     try { 
      JSONFeeds[i] = new JSONArray(mRawFeeds[i]); 
     } catch (JSONException e) { 
      e.printStackTrace(); 
     } 

     String name = ""; 
     String tweet = ""; 

     JSONArray tmp = JSONFeeds[i]; 

     // string buffer for twitter feeds 
     StringBuffer tweetRec = new StringBuffer(""); 

     for (int j = 0; j < tmp.length(); j++) { 
      try { 
       tweet = tmp.getJSONObject(j).getString("text"); 
       JSONObject user = (JSONObject) tmp.getJSONObject(j).get(
         "user"); 
       name = user.getString("name"); 

      } catch (JSONException e) { 
       e.printStackTrace(); 
      } 

      tweetRec.append(name + " - " + tweet + "\n\n"); 
     } 

     mProcessedFeeds[i] = tweetRec.toString(); 

    } 
} 

// Retrieve feeds text from a file 
// Store them in mRawTextFeed[] 

private void loadTweetsFromFile() { 
    BufferedReader reader = null; 

    try { 
     FileInputStream fis = openFileInput(TWEET_FILENAME); 
     reader = new BufferedReader(new InputStreamReader(fis)); 
     String s = null; 
     int i = 0; 
     while (null != (s = reader.readLine()) && i < NUM_FRIENDS) { 
      mRawFeeds[i] = s; 
      i++; 
     } 
    } catch (FileNotFoundException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } finally { 
     if (null != reader) { 
      try { 
       reader.close(); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } 
     } 
    } 
} 

// Simplified log output method 
private void log(String msg) { 
    try { 
     Thread.sleep(500); 
    } catch (InterruptedException e) { 
     e.printStackTrace(); 
    } 
    Log.i(TAG, msg); 
} 

}

이 두 번째 클래스 파일이며이 지역 변수 notificationBuilder 사용하지 않는라는 경고를 보여줍니다.

public class MainActivity extends Activity implements SelectionListener { 

     public static final String TWEET_FILENAME = "tweets.txt"; 
     public static final String[] FRIENDS = { "taylorswift13", "msrebeccablack", 
     "ladygaga" }; 
     public static final String DATA_REFRESHED_ACTION = "course.labs.notificationslab.DATA_REFRESHED"; 

     private static final int NUM_FRIENDS = 3; 
     private static final String URL_LGAGA = "https://d396qusza40orc.cloudfront.net/android%2FLabs%2FUserNotifications%2Fladygaga.txt"; 
     private static final String URL_RBLACK = "https://d396qusza40orc.cloudfront.net/android%2FLabs%2FUserNotifications%2Frebeccablack.txt"; 
     private static final String URL_TSWIFT = "https://d396qusza40orc.cloudfront.net/android%2FLabs%2FUserNotifications%2Ftaylorswift.txt"; 
     private static final String TAG = "Lab-Notifications"; 
     private static final long TWO_MIN = 2 * 60 * 1000; 
     private static final int UNSELECTED = -1; 

     private FragmentManager mFragmentManager; 
     private FriendsFragment mFriendsFragment; 
     private boolean mIsFresh; 
     private BroadcastReceiver mRefreshReceiver; 
     private int mFeedSelected = UNSELECTED; 
     private FeedFragment mFeedFragment; 
     private String[] mRawFeeds = new String[3]; 
     private String[] mProcessedFeeds = new String[3]; 

@Override 
     protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     mFragmentManager = getFragmentManager(); 
     addFriendsFragment(); 

    // The feed is fresh if it was downloaded less than 2 minutes ago 
     mIsFresh = (System.currentTimeMillis() - getFileStreamPath(
      TWEET_FILENAME).lastModified()) < TWO_MIN; 

     ensureData(); 

} 

// Add Friends Fragment to Activity 
     private void addFriendsFragment() { 

     mFriendsFragment = new FriendsFragment(); 
     mFriendsFragment.setArguments(getIntent().getExtras()); 

     FragmentTransaction transaction = mFragmentManager.beginTransaction(); 
     transaction.add(R.id.fragment_container, mFriendsFragment); 

     transaction.commit(); 
} 

// If stored Tweets are not fresh, reload them from network 
// Otherwise, load them from file 
     private void ensureData() { 

    log("In ensureData(), mIsFresh:" + mIsFresh); 

     if (!mIsFresh) { 

     // TODO: 
     // Show a Toast Notification to inform user that 
     // the app is "Downloading Tweets from Network" 
     log ("Issuing Toast Message"); 
       Toast.makeText(getApplicationContext(), "refreshing Tweets",Toast.LENGTH_LONG).show(); 


     // TODO: 
     // Start new AsyncTask to download Tweets from network 
      new DownloaderTask(MainActivity.this).execute(MainActivity.URL_LGAGA,MainActivity.URL_RBLACK,MainActivity.URL_TSWIFT); 





     // Set up a BroadcastReceiver to receive an Intent when download 
     // finishes. 
      mRefreshReceiver = new BroadcastReceiver() { 
      @Override 
        public void onReceive(Context context, Intent intent) { 

       log("BroadcastIntent received in MainActivity"); 

       // TODO:     
       // Check to make sure this is an ordered broadcast 
       // Let sender know that the Intent was received 
       // by setting result code to RESULT_OK 
         sendOrderedBroadcast(new Intent(), null, null, null, RESULT_OK, null, null); 

      } 
     }; 

    } else { 

      loadTweetsFromFile(); 
      parseJSON(); 
      updateFeed(); 

    } 
} 

// Called when new Tweets have been downloaded 
     public void setRefreshed(String[] feeds) { 

     mRawFeeds[0] = feeds[0]; 
     mRawFeeds[1] = feeds[1]; 
     mRawFeeds[2] = feeds[2]; 

     parseJSON(); 
     updateFeed(); 
     mIsFresh = true; 

}; 

// Called when a Friend is clicked on 
@Override 
     public void onItemSelected(int position) { 

     mFeedSelected = position; 
     mFeedFragment = addFeedFragment(); 

     if (mIsFresh) { 
       updateFeed(); 
    } 
} 

// Calls FeedFragement.update, passing in the 
// the tweets for the currently selected friend 

    void updateFeed() { 

      if (null != mFeedFragment) 

       mFeedFragment.update(mProcessedFeeds[mFeedSelected]); 

} 

// Add FeedFragment to Activity 
     private FeedFragment addFeedFragment() { 
     FeedFragment feedFragment; 
     feedFragment = new FeedFragment(); 

     FragmentTransaction transaction = mFragmentManager.beginTransaction(); 

     transaction.replace(R.id.fragment_container, feedFragment); 
     transaction.addToBackStack(null); 

     transaction.commit(); 
     mFragmentManager.executePendingTransactions(); 
     return feedFragment; 

} 

// Register the BroadcastReceiver 
@Override 
     protected void onResume() { 
     super.onResume(); 

    // TODO: 
    // Register the BroadcastReceiver to receive a 
    // DATA_REFRESHED_ACTION broadcast 
     IntentFilter intentFilter = new IntentFilter(DATA_REFRESHED_ACTION); 
      registerReceiver(mRefreshReceiver, intentFilter); 


} 

@Override 
     protected void onPause() { 

    // TODO: 
    // Unregister the BroadcastReceiver 
     unregisterReceiver(mRefreshReceiver); 



     super.onPause(); 

} 

// Convert raw Tweet data (in JSON format) into text for display 

     public void parseJSON() { 

     JSONArray[] JSONFeeds = new JSONArray[NUM_FRIENDS]; 

     for (int i = 0; i < NUM_FRIENDS; i++) { 
       try { 
        JSONFeeds[i] = new JSONArray(mRawFeeds[i]); 
      } catch (JSONException e) { 
       e.printStackTrace(); 
     } 

      String name = ""; 
      String tweet = ""; 

      JSONArray tmp = JSONFeeds[i]; 

     // string buffer for twitter feeds 
      StringBuffer tweetRec = new StringBuffer(""); 

      for (int j = 0; j < tmp.length(); j++) { 
       try { 
        tweet = tmp.getJSONObject(j).getString("text"); 
        JSONObject user = (JSONObject) tmp.getJSONObject(j).get(
         "user"); 
        name = user.getString("name"); 

       } catch (JSONException e) { 
        e.printStackTrace(); 
      } 

       tweetRec.append(name + " - " + tweet + "\n\n"); 
     } 

      mProcessedFeeds[i] = tweetRec.toString(); 

    } 
} 

// Retrieve feeds text from a file 
// Store them in mRawTextFeed[] 

     private void loadTweetsFromFile() { 
     BufferedReader reader = null; 

     try { 
      FileInputStream fis = openFileInput(TWEET_FILENAME); 
      reader = new BufferedReader(new InputStreamReader(fis)); 
      String s = null; 
      int i = 0; 
      while (null != (s = reader.readLine()) && i < NUM_FRIENDS) { 
       mRawFeeds[i] = s; 
       i++; 
     } 
     } catch (FileNotFoundException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } finally { 
      if (null != reader) { 
       try { 
        reader.close(); 
       } catch (IOException e) { 
        e.printStackTrace(); 
      } 
     } 
    } 
} 

// Simplified log output method 
     private void log(String msg) { 
     try { 
      Thread.sleep(500); 
     } catch (InterruptedException e) { 
      e.printStackTrace(); 
    } 
    Log.i(TAG, msg); 
} 
} 

나는 무엇이 잘못 되었습니까? 이 응용 프로그램은 세 사람의 트위터 피드를 표시하기로되어 있습니다. 첫 번째 사용자는 트윗이 다운로드되는 메시지 만 표시하지만 첫 번째 사용자의 트위터 피드는 표시하지 않으며 앱은이 시점을지나 실행되고 두 번째 사람이 피드를 표시합니다. 나열된 스택 추적을 던지거나 첫 번째 사람보기가 표시되지 않은 스택 추적 오류를 표시합니다 (피드는 텍스트 파일에 저장되고 androidManifest.xml에 선언됩니다. 에뮬레이터는 실제로 웹에 연결할 수 없기 때문입니다). 사전에 작성 및 강사에 의해 매니 페스트에 선언 그래서 문제는 그 중 거짓말을 믿지 않아요, 나는 자바 프로그래밍에 익숙하지 않습니다 그리고 나는 아주 잘 정통하지 그래서 나는 어딘가에 그것을 망쳐 놓을거야 두 번째 .class 파일에서.

태그가있는 LogCat은 다음과 같습니다. android 런타임 용으로 치명적인 오류를 참조한 것이므로 새 번호로 어디에서 줄 번호를 찾지 못했습니다.

02-16 17:11:06.606: D/AndroidRuntime(5278): Shutting down VM 
02-16 17:11:06.704: E/AndroidRuntime(5278): FATAL EXCEPTION: main 
02-16 17:11:06.704: E/AndroidRuntime(5278): java.lang.RuntimeException: Unable to pause  activity {course.labs.notificationslab/course.labs.notificationslab.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: null 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3064) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3019) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2997) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ActivityThread.access$800(ActivityThread.java:141) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1273) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.os.Handler.dispatchMessage(Handler.java:99) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.os.Looper.loop(Looper.java:137) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ActivityThread.main(ActivityThread.java:5103) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at java.lang.reflect.Method.invoke(Method.java:525) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at dalvik.system.NativeStart.main(Native Method) 
02-16 17:11:06.704: E/AndroidRuntime(5278): Caused by: java.lang.IllegalArgumentException: Receiver not registered: null 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:662) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1372) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:468) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at course.labs.notificationslab.MainActivity.onPause(MainActivity.java:196) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.Activity.performPause(Activity.java:5235) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1233) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3050) 
02-16 17:11:06.704: E/AndroidRuntime(5278):  ... 12 more 
02-16 17:15:19.514: D/AndroidRuntime(5361): Shutting down VM 
02-16 17:15:19.646: E/AndroidRuntime(5361): FATAL EXCEPTION: main 
02-16 17:15:19.646: E/AndroidRuntime(5361): java.lang.RuntimeException: Unable to pause activity {course.labs.notificationslab/course.labs.notificationslab.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: null 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3064) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3019) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2997) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ActivityThread.access$800(ActivityThread.java:141) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1273) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.os.Handler.dispatchMessage(Handler.java:99) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.os.Looper.loop(Looper.java:137) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ActivityThread.main(ActivityThread.java:5103) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at java.lang.reflect.Method.invoke(Method.java:525) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at dalvik.system.NativeStart.main(Native Method) 
02-16 17:15:19.646: E/AndroidRuntime(5361): Caused by: java.lang.IllegalArgumentException: Receiver not registered: null 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:662) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1372) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:468) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at course.labs.notificationslab.MainActivity.onPause(MainActivity.java:196) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.Activity.performPause(Activity.java:5235) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1233) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3050) 
02-16 17:15:19.646: E/AndroidRuntime(5361):  ... 12 more 
02-16 17:49:19.994: D/AndroidRuntime(5451): Shutting down VM 
02-16 17:49:20.104: E/AndroidRuntime(5451): FATAL EXCEPTION: main 
02-16 17:49:20.104: E/AndroidRuntime(5451): java.lang.RuntimeException: Unable to pause activity {course.labs.notificationslab/course.labs.notificationslab.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: null 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3064) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3019) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2997) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ActivityThread.access$800(ActivityThread.java:141) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1273) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.os.Handler.dispatchMessage(Handler.java:99) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.os.Looper.loop(Looper.java:137) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ActivityThread.main(ActivityThread.java:5103) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at java.lang.reflect.Method.invoke(Method.java:525) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at dalvik.system.NativeStart.main(Native Method) 
02-16 17:49:20.104: E/AndroidRuntime(5451): Caused by: java.lang.IllegalArgumentException: Receiver not registered: null 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:662) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1372) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:468) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at course.labs.notificationslab.MainActivity.onPause(MainActivity.java:196) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.Activity.performPause(Activity.java:5235) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1233) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3050) 
02-16 17:49:20.104: E/AndroidRuntime(5451):  ... 12 more 
+0

ption, 그 라인을 가리키고 있는지 확인하십시오. – user2450263

답변

0

onPause()에서 mRefreshReciver를 초기화하지 않았습니다.

ensureData()에서 mIsFresh와 상관없이 mRefreshReceiver를 초기화하려고하십시오.

+0

구문 예제를 보여 주겠습니까? 이것은 아직 배웠던 한 가지입니다. 책 자바 빠른 구문 참조로 초기화 블록의 구문을 이해하려고 시도했지만이 책에 제시된 예제는 // 정적 int [] 배열의 intialization 블록 명령문과 관련이 있습니다. array = new int [5]; 요구. 이 프로젝트에 대한 올바른 호출을하는 방법과 관련시키는 방법을 모르겠습니다. –

1

당신은 mRefreshReciver은 onPause 방법의 null 여부를 확인해야

if(mRefreshReceiver != null) 
{ 
unregisterReceiver(mRefreshReceiver); 
} 

이 문제를 해결하고 테스트를 통과 할 것이다)

이반 언급했다는 mRefreshReceiver 위에 확인에
+0

정말 도움이되지 않았나요? – downhand

0

, 당신이 필요로하는 onPostExecute()뿐만 아니라 mCallback위한 널 검사를 추가하려면 로그 캣 라인은 exce 인에 도시되어야

if (mCallback != null) { 
    mCallback.notifyDataRefreshed(strings); 
} 
관련 문제