标签:code tle tools log over xtend super 应用 creat
相信大家都看过APP上有一个选项”喜欢此APP?还希望您评价一下吧!”,然后点击弹出选择框让你选择一个市场如: 安智市场,百度应用,豌豆荚….然后选择其中一个后就跳转至此市场你的APP专栏中.
其实这里就是一个简单的意图而已:
String mAddress ="market://details?id="+getPackageName();
Intent marketIntent = new Intent("android.intent.action.VIEW");
marketIntent.setData(Uri.parse(mAddress));
startActivity(marketIntent);
getPackageName():这里可以换成其他应用的包名.
很简单吧?来看下具体案例
java代码:
package com.example.administrator.myapplication;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClick(View view) {
String mAddress ="market://details?id="+getPackageName();
Intent marketIntent = new Intent("android.intent.action.VIEW");
marketIntent.setData(Uri.parse(mAddress));
startActivity(marketIntent);
}
}
布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.administrator.myapplication.MainActivity">
<Button
android:onClick="onClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="去市场评价" />
</RelativeLayout>
标签:code tle tools log over xtend super 应用 creat
原文地址:http://blog.csdn.net/qfanmingyiq/article/details/53244111