Can't get tabs to work with intents

by jouke » Mon, 27 Jul 2009 06:44:58 GMT


Sponsored Links
 ello all,
I try to make an plication with tabs using intents and activities to
populate the different tabs. The layout seems OK but as soon as I hit
a spinner on a tab populated by an Activity (Intent) it crashes (due
to a null pointer). I made a small test application to reproduce the
error.
I'm sure I do something wrong but I can't seem to find out what.
Thanks a lot for any help,
Jouke

=== source (partly) ===

package com.jouke.test;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class Test extends TabActivity {
private TabHost mTabHost;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab1);
mTabHost = getTabHost();

mTabHost.addTab(mTabHost.newTabSpec("Tab1")
.setIndicator("Tab1")
.setContent(R.id.tab1));
Intent tab2 = new Intent(this.getApplicationContext
(),tab2.class);
mTabHost.addTab(mTabHost.newTabSpec("Tab2")
.setIndicator("Tab2")
.setContent(tab2));
}
}

----

package com.jouke.test;

import android.app.TabActivity;

public class tab1 extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab1);
}
}

----
package com.jouke.test;

import android.app.TabActivity;

public class tab2 extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab2);
}

----
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jouke.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".Test"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".tab1">
<intent-filter>
<action android:name="android.intent.action.EMBEDDED" /
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".tab2">
<intent-filter>
<action android:name="android.intent.action.EMBEDDED" /
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</mani



Other Threads

1. Inter-Activity memory restriction and API documents

Hi Mark,

I can give my app as an example. The app uses the camera API to catch a
bitmap and tries to pass the bitmap to the cropping activity. It worked on
the emulator but not on the real device because the inter-activity
limitation on memory. I can persist the data and pass it to the cropping
activity and pass the result back in the same way, but that will be very
slow. In the end I have to write my own cropping in the same activity. You
can see the cropping activity is not very useful (also, it is not documented
as well) because of the limitation.

If the two activities have the same signature or one of them (such as the
cropping) is a shared tool and provides only service (not data) then there
is no security concern. By "single process framework", I mean I can do
everything in my process and at the same time to use libraries and tools etc
from the SDK.

I really like Android but I hope it can improve on this.

Jack







--~--~---------~--~----~------------~-------~--~----~

2. How could I get the size of android.graphics.picture



It seems the only way is to add your own getSize() member function.
Please refer to skia library, class SkPicture, macro SK_DEBUG_SIZE.
You could find more information.

Thanks
--~--~---------~--~----~------------~-------~--~----~

3. JUNIT Tests results

4. OnTouchListener is not able to change ImageResource

5. audio flinger :(

6. Getting stated

7. logcat api?