Time of Update: 2018-12-08
複製代碼 代碼如下:Intent intent = new Intent("cn.pocketdigi.update.alarm"); intent.setClass(this, AlarmReceiver.class); PendingIntent pi=PendingIntent.getBroadcast(this, 0, intent,0); //設定一個PendingIntent對象,發送廣播 AlarmManager am=(AlarmManager)getSystemService(
Time of Update: 2018-12-08
MainActivity如下: 複製代碼 代碼如下:package cn.testreflect; import java.lang.reflect.Field; import android.os.Bundle; import android.widget.ImageView; import android.app.Activity; /** * Demo描述: * 依據圖片的名字,通過反射擷取其在drawable中的ID * 在根據此ID顯示圖片 */ public class
Time of Update: 2018-12-08
背景知識:可以用Activity和Service來開始訊息通知,兩者的區別在於一個是在前台觸發,一個是後台服務觸發。要使用訊息通知,必須要用到兩個類:NotificationManager和Notification,其他NotificationManager的初始化是用getSystemService方法,並且通過notify方法來向android系統發送訊息列通知和顯示。效果 :代碼:複製代碼 代碼如下://訊息通知欄 //定義NotificationManager
Time of Update: 2018-12-08
Android橫豎屏要解決的問題應該就兩個:一。布局問題;二。重新載入問題。1.布局問題:如果不想讓軟體在橫豎屏之間切換,最簡單的辦法就是在項目的 AndroidManifest.xml中找到你所指定的activity中加上android:screenOrientation屬性,他有以下幾個參數:"unspecified" 預設值 由系統來判斷顯示方向.判定的策略是和裝置相關的,所以不同的裝置會有不同的顯示方向. "landscape" 橫屏顯示(寬比高要長) "portrait"
Time of Update: 2018-12-08
在Android中,用string-array是一種簡單的提取XML資源檔資料的方法。例子如下:把相應的資料放到values檔案夾的arrays.xml檔案裡複製代碼 代碼如下:<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="city"> <item>廈門市</item> <item>福州市&
Time of Update: 2018-12-08
貼上代碼: 1.擴充Gallery: 複製代碼 代碼如下:public class GalleryFlow extends Gallery { private Camera mCamera = new Camera();//相機類 private int mMaxRotationAngle = 60;//最大轉動角度 private int mMaxZoom = -300;////最大縮放值 private int mCoveflowCenter;//半徑值 public
Time of Update: 2018-12-08
在android中,經常要用到協助、about、關於作者等的提示頁面。類似這樣的頁面:這樣的頁面,我們可以通過AlertDialog對話方塊來設計。設計一個AboutDialog類繼承於AlertDialog複製代碼 代碼如下:public class AboutDialog extends AlertDialog { public AboutDialog(Context context) { super(context); final
Time of Update: 2018-12-08
本文使用Matrix實現Android實現圖片縮放與旋轉。範例程式碼如下:複製代碼 代碼如下:package com.android.matrix;import android.app.Activity;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Matrix;import android.graphics.drawable.BitmapDrawable;
Time of Update: 2018-12-08
1、問題提出 1)為何需要多線程? 2)多線程如何?? 3)多線程機制的核心是啥? 4)到底有多少種實現方式? 2、問題分析 1)究其為啥需要多線程的本質就是非同步處理,直觀一點說就是不要讓使用者感覺到“很卡”。 eg:你點擊按鈕下載一首歌,接著該按鈕一直處於按下狀態,那麼使用者體驗就很差。 2)多線程實現方式implements Runnable 或 extends Thread 3)多線程核心機制是Handler 4)提供如下幾種實現方式 —-1—–Handler
Time of Update: 2018-12-08
file: BluetoothEventLoop.java GB/GB2/GB3: 1. import android.os.PowerManager; 2. 變數申明:private PowerManager.WakeLock mWakeLock; 3. BluetoothEventLoop(){} 建構函式裡面添加定義: PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
Time of Update: 2018-12-08
Android NDK中使用socket的整個過程分為以下幾部分:第一部分: 建立socket並綁定IP和連接埠複製代碼 代碼如下:#include <sys/select.h>#include <sys/socket.h>#include <arpa/inet.h>#define MAX_DATA_BUF_LEN 10240int sd = INVALID_SOCKET;sockaddr_in addr_org; // 發送端地址sd =
Time of Update: 2018-12-08
複製代碼 代碼如下:import java.text.SimpleDateFormat; SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss "); Date curDate = new Date(System.currentTimeMillis());//擷取目前時間 String str =
Time of Update: 2018-12-08
1. 安裝所有的套件sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386 g++-multilib mingw32 openjdk-6-jdk tofrodos
Time of Update: 2018-12-08
複製代碼 代碼如下:StringBuilder phoneInfo = new StringBuilder(); phoneInfo.append("Product: " + android.os.Build.PRODUCT + System.getProperty("line.separator")); phoneInfo.append( "CPU_ABI: " + android.os.Build.CPU_ABI + System.getProperty("line.separator"))
Time of Update: 2018-12-08
有時候我們想在標準的Framework中添加自己的新的資源怎麼辦呢?辦法就是我們來嘗試下。通過Eclipse的聯絡,我們可以聯想到是否就是簡單的把字串放在res的各個檔案夾裡面。先來試試看,編譯,系統立即報錯。為什麼呢?它提示你利用make update-api這個命令來更新public.xml檔案或者把這個聲明稱hide類型。這個肯定不是我們想要的。所以方法有二:方法1:正常添加完資源後,執行make
Time of Update: 2018-12-08
this template depends on the android support library,which is either not installed,or the template depends on a more recent version thanthe one you have installed。Required version :8安裝提示我點 install 了,但安裝後console裡面顯示的是 Installed Android Support
Time of Update: 2018-12-08
系統原來用的是BOSCH_BMA222的gsensor, 現在要求換成使用MMA7660,我們來看一下怎樣增加驅動和調試過程。 1. 修改Makefie首先,修改放置驅動的目錄裡的Makefile(kernel/driver/misc),添置如下語句:複製代碼 代碼如下:obj-$(CONFIG_SENSORS_MMA7660) += mma7660.o 2. 增加驅動檔案 把驅動檔案mma7660.c添加到kernel/driver/misc下。3.
Time of Update: 2018-12-08
通過Socket +
Time of Update: 2018-12-08
直接講用法,Crowdsourced Security Testing道怎麼用,再知道怎麼回事 1、HttpPost 複製代碼 代碼如下:try{ //建立串連 HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(url); //設定參數,仿html表單提交 List<NameValuePair> paramList = new
Time of Update: 2018-12-08
代碼如下:[java]複製代碼 代碼如下:<LinearLayout android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1" android:padding="20dp" >