欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android通過代碼的形式來實現(xiàn)應(yīng)用程序的方法

 更新時間:2013年10月04日 16:47:33   作者:  
因為應(yīng)用程序的安裝與卸載模塊在android系統(tǒng)中已經(jīng)寫好了,所以我們只需要激活就行了

注意:
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");這一句話中,第一個參數(shù)是要安裝的apk的路徑,第二個參數(shù)是apk所對應(yīng)的類型??梢栽襱omcat的安裝目錄下的conf目錄下的web.xml中找到
程序運行截圖:

 代碼實現(xiàn)如下:
1、main.xml

復(fù)制代碼 代碼如下:

<?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="vertical" >
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="安裝"
        android:onClick="install"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="卸載"
        android:onClick="uninstall"
        />
</LinearLayout>

2、MainActivity
復(fù)制代碼 代碼如下:

package com.njupt.install;
import java.io.File;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
 }
 public void install(View v){
  Intent intent = new Intent();
  intent.setAction(Intent.ACTION_VIEW);
  File file = new File(Environment.getExternalStorageDirectory(),"HtmlUI1.apk");
  intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
  startActivity(intent);
 }
 public void uninstall(View v){
  Intent intent = new Intent();
     intent.setAction(Intent.ACTION_DELETE);
     intent.setData(Uri.parse("package:com.njupt.htmlui1"));
  startActivity(intent);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.main, menu);
  return true;
 }
}

相關(guān)文章

  • android 線性布局LinearLayout實例代碼

    android 線性布局LinearLayout實例代碼

    android 線性布局LinearLayout實例代碼,需要的朋友可以參考一下
    2013-05-05
  • android獲取屏幕的長與寬實現(xiàn)代碼(手寫)

    android獲取屏幕的長與寬實現(xiàn)代碼(手寫)

    android中獲取屏幕的長于寬,參考了網(wǎng)上有很多代碼,但結(jié)果與實際不符,如我的手機是i9000,屏幕大小是480*800px,得到的結(jié)果卻為320*533,于此問題很是疑惑,于是自己寫了幾行代碼,親測一下,效果還不錯,需要了解的朋友可以參考下
    2012-12-12
  • Android變形(Transform)之Camera使用介紹

    Android變形(Transform)之Camera使用介紹

    Camera主要實現(xiàn)3D的變形,有轉(zhuǎn)動,旋轉(zhuǎn)等,Camera的源碼是由Native(本地代碼)實現(xiàn),提供的接口也比較簡單,感興趣的朋友可以參考下,或許對你學(xué)習(xí)有所幫助
    2013-02-02
  • 詳解Android首選項框架的使用實例

    詳解Android首選項框架的使用實例

    首選項這個名詞對于熟悉Android的朋友們一定不會感到陌生,它經(jīng)常用來設(shè)置軟件的運行參數(shù)。本篇文章主要介紹詳解Android首選項框架的使用實例,有興趣的可以了解一下。
    2016-11-11
  • Android Handler,Message,MessageQueue,Loper源碼解析詳解

    Android Handler,Message,MessageQueue,Loper源碼解析詳解

    這篇文章主要介紹了Android Handler,Message,MessageQueue,Loper源碼解析詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下
    2021-09-09
  • Android實現(xiàn)畫板、寫字板功能(附源碼下載)

    Android實現(xiàn)畫板、寫字板功能(附源碼下載)

    這篇文章主要介紹了Android實現(xiàn)畫板、寫字板功能的方法,文中給出了簡單的介紹和示例代碼,想要了解更多的朋友可以下載源碼進行學(xué)習(xí),感興趣的朋友們下面來一起看看吧。
    2017-01-01
  • Flutter 實現(xiàn)虎牙/斗魚 彈幕功能

    Flutter 實現(xiàn)虎牙/斗魚 彈幕功能

    這篇文章主要介紹了Flutter 實現(xiàn)虎牙/斗魚 彈幕功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-04-04
  • Kotlin自定義菜單控件

    Kotlin自定義菜單控件

    這篇文章主要為大家詳細介紹了Kotlin自定義菜單控件,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android使用系統(tǒng)自帶的相機實現(xiàn)一鍵拍照功能

    Android使用系統(tǒng)自帶的相機實現(xiàn)一鍵拍照功能

    這篇文章主要介紹了Android使用系統(tǒng)自帶的相機實現(xiàn)一鍵拍照功能,非常不錯,具有參考借鑒價值,需要的朋友參考下
    2017-01-01
  • Android接入阿里云熱修復(fù)介紹

    Android接入阿里云熱修復(fù)介紹

    大家好,本篇文章主要講的是Android接入阿里云熱修復(fù)介紹,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下
    2022-01-01

最新評論