Possible Duplicate:
Android 2.1 NullPointerException with TabWidgets
I have developed an Android application which shows a list of targets in list view, then after clicking on one of the list item it opens a tab widget having 3 tabs (Details, Map, Photo) application is developed for api 7. and is working fine on all devices devices having api 8 and above. But when i open the same application on Micromax a60 having android 2.1.1 It is getting force close.
below is the log cat i got after force close. I have tried understanding it but failed. Now if this issue is not solved i will have to upgrade micromax a60 to 2.2.
Can anyone please help me with this issue ?
01-18 12:42:36.377: E/AndroidRuntime(2505): Uncaught handler: thread main exiting due to uncaught exception
01-18 12:42:36.387: E/AndroidRuntime(2505): java.lang.NullPointerException
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.widget.TabWidget.dispatchDraw(TabWidget.java:206)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.drawChild(ViewGroup.java:1529)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.View.draw(View.java:6538)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.drawChild(ViewGroup.java:1531)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.View.draw(View.java:6538)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.widget.FrameLayout.draw(FrameLayout.java:352)
01-18 12:42:36.387: E/AndroidRuntime(2505): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1837)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewRoot.draw(ViewRoot.java:1349)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewRoot.performTraversals(ViewRoot.java:1114)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.os.Handler.dispatchMessage(Handler.java:99)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.os.Looper.loop(Looper.java:123)
01-18 12:42:36.387: E/AndroidRuntime(2505): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-18 12:42:36.387: E/AndroidRuntime(2505): at java.lang.reflect.Method.invokeNative(Native Method)
01-18 12:42:36.387: E/AndroidRuntime(2505): at java.lang.reflect.Method.invoke(Method.java:521)
01-18 12:42:36.387: E/AndroidRuntime(2505): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-18 12:42:36.387: E/AndroidRuntime(2505): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-18 12:42:36.387: E/AndroidRuntime(2505): at dalvik.system.NativeStart.main(Native Method)
01-18 12:42:36.407: E/dalvikvm(2505): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
Another thing is that this list view is in one of the tabs of tab widget. and it is also opening a tab widget. Can this be a problem ? maybe..
This method is called when list item is clicked:
private void showTargetReport(String result) {
Intent intent = new Intent(ActivityUnreadReportListForEmployee.this,
ActivityTargetDetails.class);
intent.putExtra("TARGET_DETAILS", result);
if (other_target)
intent.putExtra("OTHER_TARGET", true);
else
intent.putExtra("OTHER_TARGET", false);
startActivity(intent);
}
And this method is called when ActivityTargetDetails.class is opened
private void showTabs() {
try {
setContentView(R.layout.activity_main);
myContext = this;
Resources res = getResources(); // Resource object to get Drawables
tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
/**********************************************************************/
if (other_target) {
// Create an Intent to launch an Activity for the tab (to be
// reused)
// Initialize a TabSpec for each tab and add it to the TabHost
intent = new Intent().setClass(this,
ActivityTargetInfoOtherTarget.class);
intent.putExtra("EMPLOYEE_DETAILS", employeeDetails);
intent.putExtra("TARGET_DETAILS", targetDetails);
spec = tabHost
.newTabSpec("Target Details")
.setIndicator("Details",
res.getDrawable(R.drawable.details))
.setContent(intent);
tabHost.addTab(spec);
} else {
// Create an Intent to launch an Activity for the tab (to be
// reused)
// Initialize a TabSpec for each tab and add it to the TabHost
intent = new Intent().setClass(this, ActivityTargetInfo.class);
intent.putExtra("EMPLOYEE_DETAILS", employeeDetails);
intent.putExtra("TARGET_DETAILS", targetDetails);
intent.putExtra("LOCATION_DETAILS", locationDetails);
spec = tabHost
.newTabSpec("Target Details")
.setIndicator("Details",
res.getDrawable(R.drawable.details))
.setContent(intent);
tabHost.addTab(spec);
}
/*********************************************************************/
// Do the same for the Map Tab
Intent mapIntent = new Intent(this, ActivityMapView.class);
double targetLatitude = 0.0;
double targetLongitude = 0.0;
double distanceDifference = 0.0;
double timeSpent = 0.0;
double feedbackLatitude = 0.0;
double feedbackLongitude = 0.0;
try {
if (other_target) {
targetLatitude = Double
.parseDouble(targetObject
.getString(API_Handler.OTHER_TARGET_TABLE_LATITUDE));
} else {
targetLatitude = Double
.parseDouble(locationObject
.getString(API_Handler.LOCATION_TABLE_LOCATION_LAT));
}
} catch (Exception ex) {
targetLatitude = 0.0;
}
try {
if (other_target) {
targetLongitude = Double
.parseDouble(targetObject
.getString(API_Handler.OTHER_TARGET_TABLE_LONGITUDE));
} else {
targetLongitude = Double
.parseDouble(locationObject
.getString(API_Handler.LOCATION_TABLE_LOCATION_LONG));
}
} catch (Exception ex) {
targetLongitude = 0.0;
}
try {
distanceDifference = Double
.parseDouble(targetObject
.getString(API_Handler.TARGET_TABLE_TARGET_DISTANCE_DIFFERENCE));
} catch (Exception ex) {
distanceDifference = 0.0;
}
try {
timeSpent = Double.parseDouble(targetObject
.getString(API_Handler.TARGET_TABLE_TARGET_TIME_SPENT));
} catch (Exception ex) {
timeSpent = 0.0;
}
try {
if (other_target) {
feedbackLatitude = targetLatitude;
} else {
feedbackLatitude = Double.parseDouble(targetObject
.getString(API_Handler.TARGET_TABLE_TARGET_LAT));
}
} catch (Exception ex) {
feedbackLatitude = 0.0;
}
try {
if (other_target) {
feedbackLongitude = targetLongitude;
} else {
feedbackLongitude = Double.parseDouble(targetObject
.getString(API_Handler.TARGET_TABLE_TARGET_LONG));
}
} catch (Exception ex) {
feedbackLongitude = 0.0;
}
mapIntent.putExtra(API_Handler.PARAMETER_TARGET_LATITUDE,
targetLatitude);
mapIntent.putExtra(API_Handler.PARAMETER_TARGET_LONGITUDE,
targetLongitude);
mapIntent.putExtra(API_Handler.PARAMETER_DISTANCE_DIFFERENCE,
distanceDifference);
mapIntent.putExtra(API_Handler.PARAMETER_TIME_SPENT, timeSpent);
mapIntent.putExtra(API_Handler.PARAMETER_FEEDBACK_LATITUDE,
feedbackLatitude);
mapIntent.putExtra(API_Handler.PARAMETER_FEEDBACK_LONGITUDE,
feedbackLongitude);
spec = tabHost.newTabSpec("Map")
.setIndicator("Map", res.getDrawable(R.drawable.map))
.setContent(mapIntent);
tabHost.addTab(spec);
/**************************************************************************/
// Do the same for the photo tab
intent = new Intent().setClass(this, ActivityPhoto.class);
intent.putExtra(API_Handler.PARAMETER_TARGET_IMAGE_PATH, imagePath);
spec = tabHost.newTabSpec("Photo")
.setIndicator("Photo", res.getDrawable(R.drawable.photo))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
} catch (Exception ex) {
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
}
}