java.lang.StackOverflowError的

时间:2013-04-03 12:14:10

标签: java android sqlite stack-overflow

我从我的sqlite数据库中获取了一些文本并将其放在变量中:

opis = c.getString(11);

Cursor在我的应用程序的其余部分正常工作。 现在我调用另一个有意图的活动并发送字符串:

Intent opis = new Intent(getApplicationContext(), Popup_opis.class);
opis.putExtra("poslatOpis", opis);
startActivity(opis);

在该类中,我将该字符串放在另一个字符串中,然后将该文本设置为TextView。当我在TextView中使用单词“text”调用它时,弹出活动工作正常。现在,这是活动:

public class Popup_opis extends Activity{

    TextView opis;
    String poslatOpis, primljenOpis;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.popup_opis);

        Bundle extras = getIntent().getExtras(); 
        if(extras !=null) {
           primljenOpis = extras.getString("poslatOpis");
        }

        initVariables();

    }

    private void initVariables() {
        Typeface tv = Typeface.createFromAsset(getAssets(), "ARIALN.TTF");
        opis = (TextView) findViewById(R.id.tvOpis);
        opis.setTypeface(tv);
        opis.setText(primljenOpis);

    }

}

这是LogCat:

04-03 13:59:54.424: E/AndroidRuntime(28413): FATAL EXCEPTION: main
04-03 13:59:54.424: E/AndroidRuntime(28413): java.lang.StackOverflowError
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:484)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeToParcel(Bundle.java:1552)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeBundle(Parcel.java:502)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.content.Intent.writeToParcel(Intent.java:5503)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeParcelable(Parcel.java:1151)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeValue(Parcel.java:1070)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Parcel.writeMapInternal(Parcel.java:488)
04-03 13:59:54.424: E/AndroidRuntime(28413):    at android.os.Bundle.writeT

我做错了什么?

3 个答案:

答案 0 :(得分:6)

Intent opis = new Intent(getApplicationContext(), Popup_opis.class);
opis.putExtra("poslatOpis", opis);

您将opis意图置于意图附加内容中,在分区时创建无限递归。为intent和poslatOpis使用不同的变量名称。

答案 1 :(得分:1)

IntentString都命名为opis。你可能正在意图分配意图。将字符串包裹为额外的字符串。

答案 2 :(得分:1)

// Change
opis = c.getString(11);
// to
opisString = c.getString(11);

// and change
opis.putExtra("poslatOpis", opis);
// to
opis.putExtra("poslatOpis", opisString);