ADI*_*HAT 10 android google-play
你好朋友我正在开发一个应用程序,我有一个要求从我的应用程序重定向用户到游戏商店,我搜索了很多但没有成功..代码如下
Button1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v_arg) {
try {
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla/"));
startActivity(viewIntent);
}catch(Exception e) {
Toast.makeText(getApplicationContext(),"Unable to Connect Try Again...",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
Button2.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v_arg) {
try {
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("market://details?id=com.adeebhat.rabbitsvilla/"));
startActivity(viewIntent);
}catch(Exception e) {
Toast.makeText(getApplicationContext(),"Unable to Connect Try Again...",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
Run Code Online (Sandbox Code Playgroud)
Tus*_*rul 24
更复杂的方式:
final String appPackageName = getPackageName(); // package name of the app
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)));
}
Run Code Online (Sandbox Code Playgroud)
Piy*_*ush 11
您只需"/"要从网址中删除字符
所以会
https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla/
Run Code Online (Sandbox Code Playgroud)
至
https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla
Run Code Online (Sandbox Code Playgroud)
最后
Button1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v_arg) {
try {
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla"));
startActivity(viewIntent);
}catch(Exception e) {
Toast.makeText(getApplicationContext(),"Unable to Connect Try Again...",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
Run Code Online (Sandbox Code Playgroud)
Pan*_*mar 10
从网址中删除斜杠.您在包名后添加了额外的斜杠.
https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla/
Run Code Online (Sandbox Code Playgroud)
它应该是
https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla
Run Code Online (Sandbox Code Playgroud)
两个都应该是
Uri.parse("https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla")); // Removed slash
Run Code Online (Sandbox Code Playgroud)
和
Uri.parse("market://details?id=com.adeebhat.rabbitsvilla")); // Removed slash
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16682 次 |
| 最近记录: |