當前位置:首頁 » 安卓系統 » androidapk安裝廣播

androidapk安裝廣播

發布時間: 2022-12-06 11:50:06

Ⅰ android為什麼監聽不到應用覆蓋安裝的廣播

這里的廣播是指你app里的廣播還是手機系統的廣播。
如果是你自己手機的app的廣播,你是否有注冊監聽廣播。
如果是手機系統的廣播,因為以前所有的app開啟及運行,都以監聽手機開機廣播,後來開發商直接攔截,不讓app監聽手機開機等廣播。

Ⅱ android 怎麼自啟動應用

安裝自啟動:
要做這個功能有一個前提,那就是用戶的機器上已經裝過相應應用,也就是說只有升級APK的時候才可以這么干,因為要執行的功能需要程序的配合。
具體步驟如下:
首先要知道程序已經安裝完成,所以需要在程序中注冊一個廣播監聽(必須是靜態的,你懂的)apk安裝完成的action:"android.intent.action.PACKAGE_ADDED",在這個廣播的onReceive方法中監聽action,並通過intent.getDataString()方法判斷安裝程序的包名是否屬於自己的包名,如果是做下一步操作;
通過Intent顯式或者隱式的啟動你自己的程序。
建議:
  最好不要這樣干,你要考慮一下用戶的感受,特別是那種自動安裝不需要點確認的時候,正在玩游戲、看視頻、看小說、用微信你自動打開一個應用

開機自啟動
android實現開機自啟動可能是移動操作系統中最簡單的了,只需要監聽一個開機啟動的Broadcast(廣播)即可。首先寫一個Receiver(即廣播監聽器),繼承BroadcastReceiver。

如下所示:
public class BootReceiver extends BroadcastReceiver {
private PendingIntent mAlarmSender;
@Override
public void onReceive(Context context, Intent intent) {
// 在這里干你想乾的事(啟動一個Service,Activity等),本例是啟動一個定時調度程序,每30分鍾啟動一個Service去更新數據
mAlarmSender = PendingIntent.getService(context, 0, new Intent(context,
RefreshDataService.class), 0);
long firstTime = SystemClock.elapsedRealtime();
AlarmManager am = (AlarmManager) context
.getSystemService(Activity.ALARM_SERVICE);
am.cancel(mAlarmSender);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime,
30 * 60 * 1000, mAlarmSender);
}
}

接下來,只需要在應用程序配置文件AndroidManifest.xml中注冊這個Receiver來監聽系統啟動事件即可

如下所示:
<receiver android:name=".service.BootReceiver">
<intent-filter>
<!-- 系統啟動完成後會調用-->
<action android:name="android.intent.action.BOOT_COMPLETED">
</action>
</intent-filter>
</receiver>

Ⅲ android6.0代碼安裝apk失敗!!!

1.從google搜索內容
Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,」searchString」)
startActivity(intent);
2.瀏覽網頁
Uri uri = Uri.parse(「http://www.google.com」);
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
3.顯示地圖
Uri uri = Uri.parse(「geo:38.899533,-77.036476″);
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);
4.路徑規劃
Uri uri = Uri.parse(「http://maps.google.com/maps?」 +
「f=dsaddr=startLat startLng&daddr=endLat endLng&hl=en」);
Intent it = new Intent(Intent.ACTION_VIEW,URI);
startActivity(it);
5.撥打電話
Uri uri = Uri.parse(「tel:xxxxxx」);
Intent it = new Intent(Intent.ACTION_DIAL, uri);
startActivity(it);
需要添加許可權<uses-permission id=」android.permission.CALL_PHONE」 >
6.調用發簡訊的程序
Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra(「sms_body」, 「The SMS text」);
it.setType(「vnd.android-dir/mms-sms」);
startActivity(it);
7.發送簡訊
Uri uri = Uri.parse(「smsto:0800000123″);
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra(「sms_body」, 「The SMS text」);
startActivity(it);
String body=」this is sms demo」;
Intent mmsintent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(「smsto」, number, null));
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, true);
mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, true);
startActivity(mmsintent);
8.發送彩信
Uri uri = Uri.parse(「content://media/external/images/media/23″);
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(「sms_body」, 「some text」);
it.putExtra(Intent.EXTRA_STREAM, uri);
it.setType(「image/png」);
startActivity(it);
StringBuilder sb = new StringBuilder();
sb.append(「file://」);
sb.append(fd.getAbsoluteFile());
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(「mmsto」, number, null));
// Below extra datas are all optional.
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject);
intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body);
intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString());
intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode);
intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent);
startActivity(intent);
9.發送Email
Uri uri = Uri.parse(「mailto:[email protected]」);
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, 「[email protected]」);
it.putExtra(Intent.EXTRA_TEXT, 「The email body text」);
it.setType(「text/plain」);
startActivity(Intent.createChooser(it, 「Choose Email Client」));
Intent it=new Intent(Intent.ACTION_SEND);
String[] tos={「[email protected]」};
String[] ccs={「[email protected]」};
it.putExtra(Intent.EXTRA_EMAIL, tos);
it.putExtra(Intent.EXTRA_CC, ccs);
it.putExtra(Intent.EXTRA_TEXT, 「The email body text」);
it.putExtra(Intent.EXTRA_SUBJECT, 「The email subject text」);
it.setType(「message/rfc822″);
startActivity(Intent.createChooser(it, 「Choose Email Client」));
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, 「The email subject text」);
it.putExtra(Intent.EXTRA_STREAM, 「file:///sdcard/mysong.mp3″);
sendIntent.setType(「audio/mp3″);
startActivity(Intent.createChooser(it, 「Choose Email Client」));
10.播放多媒體
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(「file:///sdcard/song.mp3″);
it.setDataAndType(uri, 「audio/mp3″);
startActivity(it);
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, 「1″);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
11.uninstall apk
Uri uri = Uri.fromParts(「package」, strPackageName, null);
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);
12.install apk
Uri installUri = Uri.fromParts(「package」, 「xxx」, null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
13. 打開照相機
Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null);
this.sendBroadcast(i);
long dateTaken = System.currentTimeMillis();
String name = createName(dateTaken) + 「.jpg」;
fileName = folder + name;
ContentValues values = new ContentValues();
values.put(Images.Media.TITLE, fileName);
values.put(「_data」, fileName);
values.put(Images.Media.PICASA_ID, fileName);
values.put(Images.Media.DISPLAY_NAME, fileName);
values.put(Images.Media.DESCRIPTION, fileName);
values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName);
Uri photoUri = getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
startActivityForResult(inttPhoto, 10);
14.從gallery選取圖片
Intent i = new Intent();
i.setType(「image/*」);
i.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(i, 11);
15. 打開錄音機
Intent mi = new Intent(Media.RECORD_SOUND_ACTION);
startActivity(mi);
16. 打開另一程序
Intent i = new Intent();
ComponentName cn = new ComponentName(「com.yellowbook.android2″,
「com.yellowbook.android2.AndroidSearch」);
i.setComponent(cn);
i.setAction(「android.intent.action.MAIN」);
startActivityForResult(i, RESULT_OK);
17. 傳送附件
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, 「The email subject text」);
it.putExtra(Intent.EXTRA_STREAM, 「file:///sdcard/mysong.mp3″);
sendIntent.setType(「audio/mp3″);
startActivity(Intent.createChooser(it, 「Choose Email Client」));
系統action動作和服務廣播
String ADD_SHORTCUT_ACTION 動作:在系統中添加一個快捷方式。. 「android.intent.action.ADD_SHORTCUT」
String ALL_APPS_ACTION 動作:列舉所有可用的應用。
輸入:無。 「android.intent.action.ALL_APPS」
String ALTERNATIVE_CATEGORY 類別:說明 activity 是用戶正在瀏覽的數據的一個可選操作。 「android.intent.category.ALTERNATIVE」
String ANSWER_ACTION 動作:處理撥入的電話。 「android.intent.action.ANSWER」
String BATTERY_CHANGED_ACTION 廣播:充電狀態,或者電池的電量發生變化。 「android.intent.action.BATTERY_CHANGED」
String BOOT_COMPLETED_ACTION 廣播:在系統啟動後。
這個動作被廣播一次(只有一次)。 「android.intent.action.BOOT_COMPLETED」
String BROWSABLE_CATEGORY 類別:能夠被瀏覽器安全使用的 activities 必須支持這個類別。 「android.intent.category.BROWSABLE」
String BUG_REPORT_ACTION 動作:顯示 activity 報告錯誤。 「android.intent.action.BUG_REPORT」
String CALL_ACTION 動作:撥打電話。

Ⅳ 請問[教程] 如何安裝APK到Android手機上,必看!!!

手機上首先要進行一些設置:
設置——應用程序——勾選「未知源」
設置——應用程序——開發——勾選「USB 調試」
--------------------------------------------------------------------------------------------------------------
方法一利用手機內置APK安裝器
設置——應用程序——APK安裝器
只要把APK程序都放到SD卡上,就可以直接在這個內置的APK安裝器上進行軟體的安裝與卸載。
--------------------------------------------------------------------------------------------------------------
方法二利用PC客戶端android應用安裝器
可以使用PC端軟體:如91手機助手、豌豆夾等Android應用安裝器。這些Android應用安裝器中都有海量的Android應用。你首先要在PC上安裝,然後將手機連接PC,這些Android應用安裝器會自動關聯你手機設備,點擊安裝,就可以將軟體安裝到你的手機里了。
---------------------------------------------------------------------------------------------------------------------
方法三利用資源管理器
如果你手機沒有自帶APK安裝器,可以上google market下載一個「APK安裝器」。首先,你要確定你手機中有內置google market。然後,你需聯網登錄google market下載一個「APK安裝器」,推薦你使用「ASTRO資源管理器」。

熱點內容
視頻太長怎麼壓縮發微信 發布:2024-04-20 10:00:14 瀏覽:384
顯卡怎麼保存配置 發布:2024-04-20 09:28:52 瀏覽:596
校園交易網站源碼 發布:2024-04-20 09:18:54 瀏覽:701
江蘇北斗授時伺服器ip雲空間 發布:2024-04-20 08:53:50 瀏覽:931
dedecms批量上傳圖片 發布:2024-04-20 08:42:11 瀏覽:966
酷q如何編譯 發布:2024-04-20 08:41:27 瀏覽:79
安卓手機數字人民幣怎麼下載 發布:2024-04-20 08:38:21 瀏覽:114
access如何配置資料庫 發布:2024-04-20 08:37:35 瀏覽:504
手寫輸入演算法 發布:2024-04-20 08:29:31 瀏覽:258
朝夕源碼 發布:2024-04-20 08:24:15 瀏覽:276