My Phone管家(20) 應用管理 介紹PopupWindow中點擊事件

來源:互聯網
上載者:User

標籤:

My Phone管家(20) 應用管理 介紹PopupWindow中點擊事件

 android:drawableTop="@drawable/img2"//Textview中顯示圖片

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="horizontal" >    <TextView        android:id="@+id/tv_lanuch"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:drawableTop="@drawable/img2"        android:text="啟動" />    <TextView        android:id="@+id/tv_uninstall"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:drawableTop="@drawable/img1"        android:text="卸載" />    <TextView        android:id="@+id/tv_share"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:drawableTop="@drawable/img3"        android:text="分享" /></LinearLayout>

 

三者的相應點擊事件:

  (1)應用程式的啟動需要使用PackageManager根據指定的packageName

來啟動相應的應用程式  pm.getLaunchIntentForPackage(packageName);

  (2)  應用程式的卸載, 卸載完成後,重寫重新整理介面, 使用帶回傳值的啟動activity

到相應的卸載介面,

     Intent intent = new Intent(Intent.ACTION_DELETE);     intent.addCategory(Intent.CATEGORY_DEFAULT);     intent.setData(Uri.parse("package:"+packageName));

 

    

 

/**     * 啟動應用     */    public void launch(String packageName){        PackageManager pm = getPackageManager();        //獲得app啟動介面的intent        Intent intent = pm.getLaunchIntentForPackage(packageName);        startActivity(intent);    }    /**     * 卸載應用     */    public void uninstall(String packageName){        //跳轉到卸載介面        Intent intent = new Intent(Intent.ACTION_DELETE);        intent.addCategory(Intent.CATEGORY_DEFAULT);        intent.setData(Uri.parse("package:"+packageName));        startActivityForResult(intent, 0);    }    /**     * 分享應用     */    public void share(String packageName){        Intent intent = new Intent(Intent.ACTION_SEND);        intent.setType("text/plain");//發送文本        intent.putExtra(Intent.EXTRA_TEXT, packageName);        startActivity(intent);    }    public void startActivityForResult(Intent intent, int requestCode) {        initAppData();//卸載完成後,重寫重新整理介面
super.startActivityForResult(intent, requestCode); }

 

My Phone管家(20) 應用管理 介紹PopupWindow中點擊事件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.