我的OS是: Windows 10,Android用以下版本:

1.jpg

 

首先,當然要先在Google Market 上面上架,因為是要讓使用者幫自己的APP評分,所以使用者一定要可以先在 Google Market上抓得到APP

Step 1: 先在 activity_main.xml中建立一個Button

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="128dp"
        android:layout_marginLeft="128dp"
        android:layout_marginTop="120dp"
        android:text="跳轉Google Market"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.131" />

</androidx.constraintlayout.widget.ConstraintLayout>

 

Step 2: 接著在 MainActivity.java 中實作下述程式,使用 intent 方式跳轉到 APP google market的頁面,其實最主要的是導向 Google Market 的網址:

 

在實作的時候會發現,它路徑是抓 getPackageName(),這個PackageName就是上架的時候放在 AndroidManifest 上的 package 欄位,如下圖:

1.jpg

 

打完收工

Reference:

http://housecatnotes.blogspot.com/2018/05/android-app_62.html

 

 

arrow
arrow

    葛瑞斯肯 發表在 痞客邦 留言(0) 人氣()