如何从我自己的启动

问题描述:

我写一个应用程序中,我必须表明设备的主启动程序时,用户不点击按钮(这我已经把我自己的发射器)显示设备的主发射器,我尝试使用此代码,但其表示,如果我想显示设备的主启动程序只在点击链接如何从我自己的启动

public class DefaultLaunchActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_launcher); 
     btnDeviceLauncher = (Button) findViewById(R.id.button1); 
     btnDeviceLauncher.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View arg0) { 
       Intent startMain = new Intent(Intent.ACTION_MAIN); 
       startMain.addCategory(Intent.CATEGORY_LAUNCHER); 
       startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
       startActivity(startMain); 
      } 
     }); 
    } 
} 

的manifest.xml

<activity 
    android:name="com.def.launc.DefaultLaunchActivity" 
    android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen" 
    android:launchMode="singleTask" 
    android:stateNotNeeded="true" 
    > 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.HOME" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
    </intent-filter>   
</activity> 
+0

ü找到解决方案u能请告诉我,我也有同样的问题未能显示设备的主屏幕 – Erum 2015-05-11 04:54:01

首先安装我的设备,但什么上的所有应用程序,启动程序应用程序也由启动。所以,如果你写你自己的启动应用程序,并设置该应用程序为默认启动应用程序,接下来的时间有一个Intent用于启动器应用中,自己的应用程序将被启动,而不是以前的发射,因为Intent是发射器应用程序和您的应用程序现在是发射器应用程序。

所以,如果你想从启动器内部启动原始的启动器应用程序(虽然我不认为它看起来与它实际上是启动器时相同),但你必须使用包名称手动启动它如此处所述:start application knowing package name

获得实际的启动应用程序的包名是指:How can I get the package name of the current launcher in android 2.3 and above?