开发者

Start activity did not work for android emulator

I use my custom implementation tabhost. Create a new activity as follows:

public class TabsActivityGroup extends ActivityGroup {
  //
  //...
  //
  private void startGroupActivity(String activityID, Intent activityIntent) {
    final LocalActivityManager localActivityManager = getLocalActivityManager();
    Window window = localActivityManager.startActivity(activityID, activityIntent);
    // after call destroy activity window equals null on android 1.6 (emulator). Why?
    // on android 2.2 window not equal null
    if (window != null) {
     View view = window.getDecorView();
     tabsContentFrameLayout.addView(view, new ViewGroup.LayoutParams(
     ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    }
  }
  //
  //...
  //
}

But after call destroy activity:

 getLocalActivityManager().destroyActivity(className, true);

I'm trying to make call to start activity, but get window equal null from this code:

Window window = localActivityManager.startActivity(activityID, activityIntent);

On a device with firmware 2.1 (Hero) and 开发者_JAVA百科2.2 (Desire) works all good, but on emulator with android platform not work ;(

Now I am studying source code android platform 2.2, to understand why window equal null.

I will be glad of any help.

Temporary solution:

public static boolean isEmulator(Context context) {                                                                     
 TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);     
 final String deviceId = telephonyManager.getDeviceId();                                                         
 if (deviceId == null) return true;                                                                              
 if (CommonHelper.isNotNull(deviceId) && deviceId.equals(NULL_IMEI)) {return true;} else { return false;}
}

if (!isEmulator(this)) {
     getLocalActivityManager().destroyActivity(className, true);

}


Is the call right for start activity?

I see that startActivity takes only one parameter of Intent..

Kindly check. Also, embed within try/catch to get the exception if any..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜