Monday, June 20, 2011

[android-developers] crash launching a sub activity

I am crashing trying to launch a sub-activity. I have a small app to
demonstrate the problem. The main part of the app is a list view, and
when you click on an item in the list view it is supposed to launch an
activity which brings up a gallery view. The app crashes before
onCreate() is called for the TestGallery class, so I suspect I have
omitted some necessary thing in the xml for the activity description.

manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/
android"
package="randombrand.ListGallery"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />

<application android:icon="@drawable/icon"
android:label="@string/app_name">
<activity android:label="@string/app_name"
android:name=".ListGallery">
<intent-filter>
<action android:name="android.intent.action.MAIN" /
>
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:label="Manual Top"
android:name=".TestGallery">
</activity>

</application>
</manifest>

java:

public class ListGallery extends ListActivity
{
private static final String[] astrMainMenu = { "List Item 1",
"List Item 2" };


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

setListAdapter(new ArrayAdapter<String>(this,
R.layout.main,
astrMainMenu));

ListView lView = getListView();
lView.setTextFilterEnabled(true);
}

@Override
protected void onListItemClick(ListView l, View v, int
position, long id)
{
Intent intent = new Intent(this, TestGallery.class);

startActivity(intent);
}
}
stack trace for crash when I call startActivity():

ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord,
Intent) line: 2417
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord,
Intent) line: 2512
ActivityThread.access$2200(ActivityThread, ActivityThread
$ActivityRecord, Intent) line: 119
ActivityThread$H.handleMessage(Message) line: 1863
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4363
Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
thanks in advance,

Jay

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate