最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

 代碼實(shí)現(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新建水平節(jié)點(diǎn)進(jìn)度條示例

    Android新建水平節(jié)點(diǎn)進(jìn)度條示例

    這篇文章主要為大家介紹了Android新建水平節(jié)點(diǎn)進(jìn)度條示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • Android自定義View實(shí)現(xiàn)五子棋游戲

    Android自定義View實(shí)現(xiàn)五子棋游戲

    這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)五子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • Android應(yīng)用框架之應(yīng)用啟動(dòng)過程詳解

    Android應(yīng)用框架之應(yīng)用啟動(dòng)過程詳解

    這篇文章主要為大家詳細(xì)介紹了Android應(yīng)用框架,應(yīng)用啟動(dòng)過程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android開發(fā)中的數(shù)據(jù)庫事務(wù)用法分析

    Android開發(fā)中的數(shù)據(jù)庫事務(wù)用法分析

    這篇文章主要介紹了Android開發(fā)中的數(shù)據(jù)庫事務(wù)用法,分析了Android數(shù)據(jù)庫事務(wù)的功能、使用方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2016-06-06
  • fragment實(shí)現(xiàn)隱藏及界面切換效果

    fragment實(shí)現(xiàn)隱藏及界面切換效果

    這篇文章主要為大家詳細(xì)介紹了fragment實(shí)現(xiàn)隱藏及界面切換效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-11-11
  • 詳解Kotlin Android開發(fā)中的環(huán)境配置

    詳解Kotlin Android開發(fā)中的環(huán)境配置

    這篇文章主要介紹了詳解Kotlin Android開發(fā)中的環(huán)境配置的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • Flutter組件開發(fā)過程完整講解

    Flutter組件開發(fā)過程完整講解

    這篇文章主要介紹了Flutter組件開發(fā)過程,F(xiàn)lutter是Google開源的構(gòu)建用戶界面(UI)工具包,幫助開發(fā)者通過一套代碼庫高效構(gòu)建多平臺(tái)精美應(yīng)用,支持移動(dòng)、Web、桌面和嵌入式平臺(tái)。Flutter 開源、免費(fèi),擁有寬松的開源協(xié)議,適合商業(yè)項(xiàng)目
    2022-11-11
  • SharedPreference引發(fā)ANR原理詳解

    SharedPreference引發(fā)ANR原理詳解

    這篇文章主要為大家介紹了SharedPreference引發(fā)ANR原理詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • Flutter實(shí)現(xiàn)視頻壓縮功能的示例代碼

    Flutter實(shí)現(xiàn)視頻壓縮功能的示例代碼

    移動(dòng)應(yīng)用程序中,視頻占用了大量的存儲(chǔ)空間和帶寬,這在一定程度上影響了應(yīng)用程序的性能和用戶體驗(yàn),所以本文為大家準(zhǔn)備了Flutter實(shí)現(xiàn)視頻壓縮的方法,需要的可以參考一下
    2023-06-06
  • Android中shape的自定義藝術(shù)效果使用

    Android中shape的自定義藝術(shù)效果使用

    大家好,本篇文章主要講的是Android中shape的自定義藝術(shù)效果使用,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-01-01

最新評(píng)論

南开区| 五河县| 浠水县| 都江堰市| 钟山县| 类乌齐县| 延长县| 嘉兴市| 通渭县| 鹿邑县| 清流县| 永年县| 驻马店市| 利辛县| 朝阳县| 无棣县| 财经| 通渭县| 新邵县| 资中县| 陇西县| 宁晋县| 比如县| 浦县| 乡宁县| 天祝| 万宁市| 原平市| 上杭县| 始兴县| 绿春县| 隆回县| 得荣县| 南城县| 乌什县| 瓦房店市| 兴国县| 马边| 遵义县| 剑川县| 蓝田县|