目前分類:功能 (37)
- Jun 09 Tue 2020 12:10
android pass by function
- Feb 06 Thu 2020 17:17
android startForegroundService
- Feb 06 Thu 2020 16:46
android 權限管制呼叫來源者
1.權限宣告(be called AndroidManifest.xml)
<permission android:name="package.permissionDeclare" android:protectionLevel="signature"></permission> //protectionLevel 管制permission等級
Activity、service、receiver、Provider都可以使用
- Jan 30 Thu 2020 18:27
android gson json to array
val listType: Type = object : TypeToken<ArrayList<JavaBean?>?>() {}.type var JavaBeanList : List<JavaBean> = Gson().fromJson(it, listType)
- Jan 30 Thu 2020 16:53
android aidl callback
IListener.aidl(callback)
interface IListener { void callback(String callbackString); }
IManager.aidl(server)
- Jan 15 Wed 2020 16:48
android silent install
1.create TestDeviceAdminReceiver class
public class TestDeviceAdminReceiver extends DeviceAdminReceiver { @Override public void onEnabled(final Context context, Intent intent) { super.onEnabled(context, intent); Log.d("test", "Device Owner Enabled"); } @Override public void onDisabled(Context context, Intent intent) { super.onDisabled(context, intent); } }
2.create device_admin.xml
- Jan 14 Tue 2020 15:45
android取得app資料夾
packageManager.getPackageInfo(packageName,0).applicationInfo.dataDir
- Dec 24 Tue 2019 14:54
android跨user操作同一個系統服務
1.AndroidManifest.xml宣告系統權限
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="" android:sharedUserId="android.uid.system">
2.AndroidManifest.xml宣告系統應用程式
- Dec 24 Tue 2019 14:33
android IPC之AIDL
1.AndroidManifest.xml 宣告對外service
<service android:name=".UserControlService"> <intent-filter> <action android:name="1"></action> </intent-filter> </service>
2.service server AIDL (實作AIDL interface給client端使用)
- Dec 23 Mon 2019 11:39
android pid & uid
- Dec 18 Wed 2019 18:09
跨user的application溝通
1.需要以下權限
INTERACT_ACROSS_USERS (signature|system)
- Dec 13 Fri 2019 11:59
android muti-user control
新增:adb shell pm create-user userName
移除:adb shell pm remove-user UserID
- Oct 08 Tue 2019 15:40
LiveDataBus替代eventBus及Rxbus
- Sep 06 Fri 2019 18:44
android啟動google語音辨識的兩個方法
- Sep 06 Fri 2019 16:35
android 6.0 請求多個危險權限
- Aug 30 Fri 2019 13:50
android6.0以上檢查權限
private final static int REQUEST_CONTACTS = 1;//自定義回傳數值
@Override
protected void onCreate(Bundle savedInstanceState) {
int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR);//權限確認 if(permission != PackageManager.PERMISSION_GRANTED){//沒有獲得全縣 ActivityCompat.requestPermissions( this, new String[]{Manifest.permission.READ_CALENDAR}, REQUEST_CONTACTS );//要求權限 }
}
- Sep 28 Fri 2018 17:37
android content provider
androidManifest.xml 宣告provider
<provider android:authorities="testContentProvider" //content://testContentProvider android:name=".content"> //class名稱 </provider>
- Sep 20 Thu 2018 11:46
android 跑馬燈
activity
textview.setSelected(true)
- Sep 03 Mon 2018 15:17
android語音轉文字
public class rec extends Service(Activity) implements RecognitionListener
private Intent recognizerIntent; private SpeechRecognizer mSpeechRecognizer;
oncreat初始化
recognizerIntent = new Intent();
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);//指回傳一個結果
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new ComponentName("com.google.android.googlequicksearchbox", "com.google.android.voicesearch.serviceapi.GoogleRecognitionService"));//指定使用ok google
mSpeechRecognizer.setRecognitionListener(this);//連結RecognitionListener
啟動錄音
- Aug 20 Mon 2018 11:53
android serivce啟動狀態
START_STICKY:如果service进程被kill掉,保留service的状态为开始状态,但不保留递送的intent对象。随后系统会尝试重新创建service,由于服务状态为开始状态,所以创建服务后一定会调用onStartCommand(Intent,int,int)方法。如果在此期间没有任何启动命令被传递到service,那么参数Intent将为null。
START_NOT_STICKY:“非粘性的”。使用这个返回值时,如果在执行完onStartCommand后,服务被异常kill掉,系统不会自动重启该服务。
START_REDELIVER_INTENT:重传Intent。使用这个返回值时,如果在执行完onStartCommand后,服务被异常kill掉,系统会自动重启该服务,并将Intent的值传入。
START_STICKY_COMPATIBILITY:START_STICKY的兼容版本,但不保证服务被kill后一定能重启。