- 浏览: 47591 次
- 性别:
- 来自: 苏州
最新评论
文章列表
private void doMasterClear() {
Intent intent = new Intent(Intent.ACTION_FACTORY_RESET);
intent.setPackage("android");
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(Intent.EXTRA_REASON, "MasterClearConfirm");
intent.putExtra(Intent.EXT ...
android 源碼開發環境配置
- 博客分类:
- Android 应用
一. 通用Android环境和工具配置
1. 系统更新升级
sudo apt-get update
sudo apt-get upgrade
2. 配置ntlmaps代理上网环境(本公司网络需要代理)
sudo apt-get update
sudo apt-get install ntlmaps
Parent proxy:cnkusisal
Parent proxy port:8080
NT Windows domain:xxxcn
首先需要在/frameworks/base/core/res/res/values/strings.xml裏定義新增的String:
phase1:
<string name="global_prompt_zipfile_title" translatable="false">@string/prompt_zipfile_title</string>
<string name="global_prompt_zipfile_message" translatable="fal ...
調用注冊廣播:
private IntentFilter intentFilter ;
private receiveBroadcastReceiver mreceiveDialogBroadcastReceiver;
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.receiveotamessage.broadcast");
mreceiveDialogBroadcastReceiver = new receiveBroadcastRece ...
1.將String 路徑解析成Uri的方法:
public Uri queryUriforAudio(String path)
{
File file = new File(path);
Log.i("TEST","-------->path: "+path);
final String where = MediaStore.Audio.Media.DATA + "='"+file.getAbsolutePath()+"'";
...
android 中獲取內部SD卡存儲路徑是有標準API的如下:
String internalSDPath = Environment.getExternalStorageDirectory().getAbsolutePath();
外部SD卡路徑的獲取方法如下:
先遍歷掛載的外部設備
public ArrayList<String> getExternalStorageList() {
ArrayList storageList = new ArrayList();
try {
StorageMan ...
android 时间大小比较
- 博客分类:
- Android 应用
private void TimeCompare(){
//格式化时间
SimpleDateFormat CurrentTime= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date1="2015-01-25 09:12:09";
String date2="2015-01-29 09:12:11";
try {
Date beginTime=Curren ...
在android 程序裏執行adb logcat 指令,並把執行結果保存到文件裏.代碼如下:
java.lang.Process process;
private void logcat(){
try {
process = Runtime.getRuntime().exec("logcat");
new Thread() {
@Override
public void run() {
...
android 解析zip文件
- 博客分类:
- Android 应用
private void readZipFile(String file){
ZipFile zf = null;
try {
zf = new ZipFile(file);
InputStream in = new BufferedInputStream(new FileInputStream(file));
ZipInputStream zin = new ZipInputStream(in);
ZipEntry ze;
w ...
android 中添加Dialog
- 博客分类:
- Android 应用
帶進度條的Dialog:
private void showProgess(int progress) {
try {
mHandler.post(() -> {
if (dialog == null) {
dialog = new ProgressDialog(UpdateOTAImage.this);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
...
AlarmManager 可以設置固定時間,固定周期性的操作
120秒後每60秒調用一次UpdateService:
private void setAlarmTime(){
Slog.i("TEST", "Start self-define alarm");
currentSystemTime = System.currentTimeMillis();
try {
nextCheckAlarmTime = Long.parseLong(Settings.System ...
關鍵代碼如下:
class SettingsObserver extends ContentObserver {
SettingsObserver(Handler handler) {
super(handler);
}
void observe() {
// Observe all users' changes
ContentResolver resolver = mSystemContext.getContentResolver();
...
private void updateSuccessNotification(boolean isPass){
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
String id = "update_success";
String name = "update_success_notification";
NotificationManager n ...
<div class="iteye-blog-content-contain" style="font-size: 14px"></div>android代碼 中執行shell命令的方法private String exec(String command) { try { java.lang.Process process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedRe ...
使用adb shell am 指令調用APK時,需要傳入一些指令供APK使用:
Exp:
adb shell am start -n com.example.simpleadapter/com.example.simpleadapter.MainActivity -e “stringValue” abc
在程序裏的接受部分實現code如下:
private Intent intent;
String stringVal;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(sa ...