A apk B apk引き上げ
9359 ワード
ComponentName componetName = new ComponentName("com.chinamobile.mcloud",
"com.chinamobile.mcloud.client.service.ActivatorService");
try {
Intent intent = new Intent();
intent.setComponent(componetName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("packageName",getPackageName());//
startService(intent);
} catch (Exception e) {
e.printStackTrace();
}
package com.liangMei.hjlb.moudle.my;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.liangMei.hjlb.R;
import com.liangMei.hjlb.framework.app.BaseActivity;
import java.io.File;
/**
* @Example
* @Auth : LiBo on 2019/2/25 0025
* @Describe :
*/
public class MainActivity extends BaseActivity {
public static Intent getLauncherIntent(Activity activity) {
Intent intent = new Intent(activity, MainActivity.class);
return intent;
}
//--- ID
private String TaoBaoShopId = "131259851"; //--
private String JDShopId = "1000004123"; //--
private String TaoBaoGoodsId = "525249416835"; //-- ...
private String JDGoodsId = "4099139"; //-- 6
//--1.
private String taobaoAppStr_shop = "taobao://shop.m.taobao.com/shop/shop_index.htm?shop_id=" + TaoBaoShopId + "";
private String taobaoWebStr_shop = "https://shop.m.taobao.com/shop/shop_index.htm?shop_id=" + TaoBaoShopId + "";
private String jdAppStr_shop = "openApp.jdMobile://virtual?params={\"category\":\"jump\",\"des\":\"jshopMain\",\"shopId\":\"" + JDShopId + "\",\"sourceType\":\"M_sourceFrom\",\"sourceValue\":\"dp\"}";
private String jdWebStr_shop = "http://shop.m.jd.com/?shopId=" + JDShopId + "";
//--2.
private String taobaoAppStr_goods = "taobao://item.taobao.com/item.htm?id=" + TaoBaoGoodsId + "";
private String taobaoWebStr_goods = "https://item.taobao.com/item.htm?id=" + TaoBaoGoodsId + "";
private String jdAppStr_goods = "openApp.jdMobile://virtual?params={\"category\":\"jump\",\"des\":\"productDetail\",\"skuId\":\"" + JDGoodsId + "\",\"sourceType\":\"JSHOP_SOURCE_TYPE\",\"sourceValue\":\"JSHOP_SOURCE_VALUE\"}";
private String jdWebStr_goods = "https://item.m.jd.com/product/" + JDGoodsId + ".html";
//--3.
private String mJDMall = "com.jingdong.app.mall";
private String mTaoBao = "com.taobao.taobao";
/**
* 1. QQ , QQ ( QQ ).
* String url="mqqwpa://im/chat?chat_type=wpa&uin=1642084864";
* startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
* // QQ uin 。
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mainq);
initView();
}
@Override
protected void initLogics() {
}
private void initView() {
findViewById(R.id.jump_to_jd).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//---jd
if (isInstallByread(mJDMall)) {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(jdAppStr_shop));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(jdWebStr_shop));
startActivity(intent);
// loadApp(mJDMall);
}
}
});
findViewById(R.id.jump_to_taobao).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//---taobao
if (isInstallByread(mTaoBao)) {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(taobaoAppStr_shop));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(taobaoWebStr_shop));
startActivity(intent);
// loadApp(mTaoBao);
}
}
});
findViewById(R.id.jump_to_jd_goods).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//---jd
if (isInstallByread(mJDMall)) {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(jdAppStr_goods));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(jdWebStr_goods));
startActivity(intent);
// loadApp(mJDMall);
}
}
});
findViewById(R.id.jump_to_taobao_goods).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//---taobao
if (isInstallByread(mTaoBao)) {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(taobaoAppStr_goods));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
Toast.makeText(MainActivity.this, " ", Toast.LENGTH_LONG).show();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(taobaoWebStr_goods));
startActivity(intent);
// loadApp(mTaoBao);
}
}
});
}
/**
*
*
* @param packageName
* @return
*/
private boolean isInstallByread(String packageName) {
return new File("/data/data/" + packageName).exists();
}
/**
*
*
* @param packageName
*/
private void launchApp(String packageName) {
PackageManager packageManager = this.getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
startActivity(intent);
}
/**
*
*
* @param packageName
*/
private void loadApp(String packageName) {
Uri uri = Uri.parse("market://details?id=" + packageName);//id
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
}