zoukankan      html  css  js  c++  java
  • Android需求之点击跳转至市场评价

    相信大家都看过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():这里可以换成其他应用的包名.

    很简单吧?来看下具体案例

    案例

    1. 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);
          }
      }
      
    2. 布局文件

    <?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>
    
  • 相关阅读:
    内存管理3 Win32汇编语言056
    高级强制类型转换 C++快速入门37
    内存管理3 Win32汇编语言056
    密码学基础
    危险API的禁用列表
    危险API的禁用列表
    《那些年啊,那些事——一个程序员的奋斗史》——68
    《那些年啊,那些事——一个程序员的奋斗史》——68
    《那些年啊,那些事——一个程序员的奋斗史》——68
    春节期间停止更新
  • 原文地址:https://www.cnblogs.com/muyuge/p/6152102.html
Copyright © 2011-2022 走看看