我想有我的利率按钮在我的对话框启动市场,并去我的特定应用程序。
也我如何在消息体添加到这个对话框?
private void makeDialog() {
AlertDialog.Builder about = new AlertDialog.Builder(this);
about.setMessage("About The Giveaway");
about.setPositiveButton("Rate", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
//action
}
});
about.setNegativeButton("Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {}
});
about.show();
}
}
我写了一个简单的库来做这个。
它叫做AppRate,你可以在GitHub上找到它。
特点:
- 如果应用程序崩溃一次,不提示用户。
- 决定何时提示用户。(发射次数…)
- 自定义速率对话框以适合您的应用程序设计。
使用例子:
非常容易安装和使用:
将jar放到你的libs
文件夹中。
然后在您的MAIN
活动的onCreate
方法中包含以下代码。
new AppRate(this)
.setShowIfAppHasCrashed(false)
.setMinDaysUntilPrompt(0)
.setMinLaunchesUntilPrompt(20)
.init();
- 此代码将在20次启动后显示默认速率对话框。
- 只有当应用程序从未崩溃时才会显示。
- 速率按钮指向你的应用程序在Google Play商店。
我希望这能帮助你。:)
你可以使用Intent来启动Market应用。把这个添加到你的positiveButton onClick(用你的应用URL替换URL)
Intent browserIntent = new Intent(
"android.intent.action.VIEW",
Uri.parse("https://market.android.com/details?id=com.animoca.prettyPetSalon");
startActivity(browserIntent);