更多SDK工作原理:用户在游戏中点击更多游戏按钮或图标后,游戏先判断用户手机中是否安装爱游戏客户端,如果有,则打开爱游戏客户端,没有,则使用默认浏览器打开http://play.cn/
具体调用代码如下:
public class
MainActivity extends
Activity {
Activity thisActivity;
Button button1;
public static final
String egameAppPackageName = "com.egame"
;
@Override
protected void
onCreate
(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
thisActivity = this
;
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(button1_OnClickListener);
}
private
OnClickListener button1_OnClickListener = new
OnClickListener() {
@Override
public void
onClick
(View v) {
try{
Intent intent = getPackageManager().getLaunchIntentForPackage(
egameAppPackageName);
startActivity(intent);
}catch
(Exception ex){
Intent intent = new
Intent("android.intent.action.VIEW"
);
intent.setData(Uri.parse("http://play.cn/"
));
startActivity(intent);
}
}
};
private boolean
IsAppExist
(String appPackageName) {
if (appPackageName == null
|| appPackageName.equals(""
))
return false
;
try
{
ApplicationInfo appInfo = getPackageManager().getApplicationInfo(
appPackageName, PackageManager.GET_UNINSTALLED_PACKAGES);
return true
;
} catch
(Exception ex) {
return false
;
}
}
}