2016-08-29 7 views
-2

他のアクティビティを呼び出そうとしていますが、例外がスローされています。ここでは、コードは次のようになります。Intentに致命的な例外がスローされる

ここ
public static Intent newIntent(Context packageContext, boolean answerIsTrue) { 
    Intent i = newIntent(packageContext, answerIsTrue);//This line throwing exception 
    i.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue); 
    return i; 
}; 

そしてLogcat:

08-29 05:05:52.061 2457-2457/com.bbn.geoquiz E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.bbn.geoquiz, PID: 2457 
java.lang.StackOverflowError: stack size 8MB 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at com.bbn.geoquiz.CheatActivity.newIntent(CheatActivity.java:17) 
at 
08-29 05:05:53.550 2457-2457/com.bbn.geoquiz E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 17527860) 
08-29 05:05:53.550 2457-2457/com.bbn.geoquiz E/AndroidRuntime: Error reporting crash 
android.os.TransactionTooLargeException: data parcel size 17527860 bytes 
    at android.os.BinderProxy.transactNative(Native Method) 
    at android.os.BinderProxy.transact(Binder.java:503) 
    at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4425) 
    at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:90) 
    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693) 
    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690) 

あなたはこのエラーを修正する方法をしてくださいお勧めしてもらえますか?あなたは無限ループを引き起こしている

+0

'意向I = newIntent(packageContext、answerIsTrue);' '新しいテント(#Context、#Class);'しかし、あなたがあなたの代わりにクラス名を渡すべきであるブール – Sanoop

+1

を渡しています2番目のパラメータとしてブール値を渡す – Sanoop

+0

@Sanoop、ありがとう、私は署名を変更しようとしましょう。 –

答えて

0

、コードは次のようになります。

public static Intent newIntent(Context packageContext, Class<?> clazz, boolean answerIsTrue) { 
    Intent i = new Intent(packageContext, clazz); 
    i.putExtra(EXTRA_ANSWER_IS_TRUE, answerIsTrue); 
    return i; 
} 
0

あなたが言及した行で停止せずに再帰的に同じメソッドを呼び出しています。

Intent i = newIntent(packageContext, answerIsTrue); 

ロジックをコードフローに修正してください。

1

これらはIntent

Intent() 

ためのパブリックコンストラクタが空の意図を作成します。

Intent(Intent o) 

コピーコンストラクタ。

Intent(String action) 

特定の操作でインテントを作成します。

Intent(String action, Uri uri) 

特定のアクションと指定のデータURLに対してインテントを作成します。

Intent(Context packageContext, Class<?> cls) 

特定のコンポーネントの意図を作成します。

Intent(String action, Uri uri, Context packageContext, Class<?> cls) 

指定されたアクションとデータとの特定のコンポーネントのための意図を作成します。

In your case you are passing boolean as the second parameter, where you need to pass the class name as the second parameter

+0

wow perfect ...(Y) –

+0

@ andrey.shedkoそれは受け入れられる回答でなければなりません。 –

+0

_あなたの場合は、2番目のパラメータとしてbooleanを渡しています。... ---彼は 'newIntent'の独自の実装を繰り返し呼び出しています。これが 'StackOverflowError'の理由です。 – ozbek

関連する問題