一个app打开另一个子app+子app安装不在手机桌面显示
2017-04-01 09:43
537 查看
老板临时让我做一个demo ,实现一个app打开另一个app
要求:点击打开按钮,已安装过的话 打开,没有安装显示安装
子程序不能再手机页面显示图标
父程序核心代码
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
//com.example.demo2 :子程序包名 com.example.demo2.MainActivity:子程序打开页面
ComponentName cn = new ComponentName("com.example.demo2","com.example.demo2.MainActivity");
intent.setComponent(cn);
intent.setAction("android.intent.action.MAIN");
try {
startActivityForResult(intent, RESULT_OK);
} catch (Exception e) {
Toast.makeText(MainActivity.this, "没有子APP,请下载安装",Toast.LENGTH_SHORT).show();
}
}
子程序 只需要在manifest文件下 设置一行代码
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.demo2.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->//注释掉这一行
</intent-filter>
</activity>
</application>
要求:点击打开按钮,已安装过的话 打开,没有安装显示安装
子程序不能再手机页面显示图标
父程序核心代码
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
//com.example.demo2 :子程序包名 com.example.demo2.MainActivity:子程序打开页面
ComponentName cn = new ComponentName("com.example.demo2","com.example.demo2.MainActivity");
intent.setComponent(cn);
intent.setAction("android.intent.action.MAIN");
try {
startActivityForResult(intent, RESULT_OK);
} catch (Exception e) {
Toast.makeText(MainActivity.this, "没有子APP,请下载安装",Toast.LENGTH_SHORT).show();
}
}
子程序 只需要在manifest文件下 设置一行代码
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.demo2.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->//注释掉这一行
</intent-filter>
</activity>
</application>
相关文章推荐
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景
- App安装后不在桌面显示图标
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- 转Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- android:如果手机安装了app则打开一个activity,如果没有安装则去到android market如何在HTML页面实现
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- android:如果手机安装了app则打开一个activity,如果没有安装则去到android market如何在HTML页面实现
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- IOS APP安装后不在桌面显示图标、改变图标等
- Android APP安装后不在桌面显示图标的应用场景举例和实现方法
- 如何安装的apk不在桌面上显示,并在自己的代码中启动启动
- 通过包名打开另外一个应用程序和获取手机中已安装apk文件信息(PackageInfo、ResolveInfo)