需要一个应用程序才能将意图发送给特定的收件人。 这一决定导致了该应用程序从市场上的撤消。
原因:违反欺骗性广告政策。
“打印”按钮-> GooglePlay
protected void sendToPrint(Intent intent) {
final String appPackageName = "........";
PackageManager pm = getPackageManager();
// check app installed
PackageInfo pi = null;
if (pm != null) {
try {
pi = pm.getPackageInfo(appPackageName, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
if (pi == null) {
// go to install
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
} else {
// send to print
intent.setPackage(appPackageName);
startActivity(intent);
}
}
如何最小化代码以符合要求?
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.dialog_message)
.setTitle(R.string.dialog_title);
builder.setPositiveButton(R.string.btn_install, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
});
AlertDialog dialog = builder.create();
dialog.show();
Is it correct ? 恐怕这似乎也是无法完成的事情。 https://play.google.com/about/monetization-ads/ads/deceptive/
答案 0 :(得分:0)
我这样更改了代码 https://github.com/402d/DemoRawBtPrinter/commit/1bb45e5a8f9b24f2ad9cc902f2285fc376e8909c
添加定制AlertDialog 该应用已返回GooglePlay。现在,在它超过48小时。