我真的需要如何从我的应用程序打开另一个带有按钮的特定包名称的apk。我的意思是当用户点击生成时 另一个包名为com.calculator2.yazid的应用程序将启动
我真的想要使用这个插件https://github.com/lampaa/com.lampa.startapp
答案 0 :(得分:2)
我从Tabs示例项目的标准联系页面开始,并安装了lampaa的startUp插件: 离子插件添加com.lampa.startapp
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Platform } from 'ionic-angular';
export const myConst = {
blackboardApp: {
ios: {
storeUrl: 'itms-apps://itunes.apple.com/nl/app/blackboard-mobile-learn/id376413870?mt=8',
appId: 'bblearn://'
},
android: {
storeUrl: 'market://details?id=com.blackboard.android',
appId: 'com.blackboard.android'
}
}
}
@Component({
selector: 'page-contact',
templateUrl: 'contact.html'
})
export class ContactPage {
constructor(public navCtrl: NavController, public plt: Platform) {
}
openBB() {
if (this.plt.is('android')) {
let appId = myConst.blackboardApp.android.appId;
let appStarter = (window as any).startApp.set({ "package": appId });
appStarter.start(function (msg) {
console.log('starting BB app: ' + msg);
}, function (err) {
console.log('BB app not installed', err);
window.open(myConst.blackboardApp.android.storeUrl, '_system');
});
} else if (this.plt.is('ios')) {
let appId = myConst.blackboardApp.ios.appId;
let appStarter = (window as any).startApp.set(appId);
appStarter.start(function (msg) {
console.log('starting BB app: ' + msg);
}, function (err) {
console.log('BB app not installed', err);
window.open(myConst.blackboardApp.ios.storeUrl, '_system'
);
});
} else {
let msg_err = "Platform not supported";
alert(msg_err);
console.log(msg_err);
}
}
}
希望它有所帮助! Source