Time of Update: 2018-12-06
package com.eboy.checksimoperator;import android.app.Activity;import android.content.Context;import android.os.Bundle;import android.telephony.TelephonyManager;import android.view.Menu;import android.view.View;import android.widget.Toast;public class
Time of Update: 2018-12-06
/** * * @param aUrl 網址 * @param aEncode 編碼 * @return 返回的HTML代碼 * @throws Exception 對外拋出異常 */ public String getHTML(String aUrl, String aEncode) throws Exception { URL url = new URL(aUrl); HttpURLConnection co
Time of Update: 2018-12-06
package com.eboy.testnotification;import android.app.Activity;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Context;import android.content.Intent;import android.net.Uri;
Time of Update: 2018-12-06
main.xml <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"
Time of Update: 2018-12-06
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.button1).setOnClickListener(new Button.OnClickListener() {
Time of Update: 2018-12-06
項目中需要對使用者輸入的資訊進行儲存,然後在後續程式中讀取使用,利用到了SharedPreferences類。儲存操作通常會在onPause()方法中進行Preferences的儲存操作。public SharedPreferences getSharedPreferences (String name, int mode)其中name為Preferences的檔案名稱mode有以下三種:MODE_PRIVATE 表示當下應用程式專用MODE_WORLD_READABLE
Time of Update: 2018-12-06
布局特別之處://與上一控制項底部的距離android:layout_marginTop="10dp"代碼階段分析://返回可畫的視圖,並用向下轉型為Bitmap的可畫視圖BitmapDrawable bitmapDrawable = (BitmapDrawable) image1.getDrawable();//如果圖片還未回收,先強制回收該圖片if (!bitmapDrawable.getBitmap().isRecycled()) { bitmapDrawable.getBitmap().
Time of Update: 2018-12-06
必須在AndroidManifest中設定相應的許可權:android:name="android.permission.RECORD_AUDIO" 1. 首先判定是否存在SD卡,並得到相應的路徑 /* 檢測是否存在SD卡 */ if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {/* 得到SD卡得路徑 */ mRecAudioPath =
Time of Update: 2018-12-06
建立捷徑是需要在案頭中長按,然後選擇shortcut,然後在選擇需要建立捷徑的程式。以下是步驟:1. 首先,需要在AndroidManifest中添加<action android:name="android.intent.action.CREATE_SHORTCUT" /> 1A. 判斷是否要添加捷徑:if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT))2. 建立一個Intent對象3.
Time of Update: 2018-12-06
以下使用的是SDK內建的例子來進行分析:首先,需要在 AndroidManifest.xml中添加<action android:name= "android.intent.action.CREATE_LIVE_FOLDER" />然後如下分析: public class MyLiveFolder extends Activity { public static final Uri CONTENT_URI = Uri.parse("content://my.app/live"
Time of Update: 2018-12-06
因為此代碼裡面有解釋,因此直接上代碼:public class ChangeBitmapPixel extends Activity { private Button btn; private Bitmap photo; private ImageView image; FileOutputStream fos = null; BufferedOutputStream bos = null; private ByteArrayOutputStream baos
Time of Update: 2018-12-06
Tab LayoutTo create a tabbed UI, you need to use a TabHost and a TabWidget. The TabHost must be the root node for the layout, which contains both the TabWidget for displaying the tabs and aFrameLayout for displaying the tab content.You can implement
Time of Update: 2018-12-06
Android原有的屬性可能不能滿足我們現在要做的事,畢竟有些人就是會天馬行空的想出一些Android不會做的東西。今天就簡單的寫下怎樣為自訂控制項自訂屬性,看這種描述有點暈,轉過來就是控制項和屬性都是自訂的吧。哈~上面是運行介面,有兩個自訂的Button,主要是用來區分。首先在res/values/目錄下建立attrs.xml檔案,用來自訂屬性<?xml version="1.0" encoding="utf-8"?><resources>
Time of Update: 2018-12-06
在AndroidManifest中註冊相應的許可權:<uses-permission android:name="android.permission.FLASHLIGHT" /> <uses-permission android:name="android.permission.CAMERA"/> <uses-feature android:name="android.hardware.camera" /><uses-feature
Time of Update: 2018-12-06
注意:我們建立Handler的對象調用post方法,然後傳遞進去一個Runnable對象的這種方式並不會建立一個新的線程。HandlerThread和Looper :HandlerThread是Thread的子類以下是應用程式框架: 1. 首先建立 HandlerThread對象2. 對用HandlerThread對象的start方法啟用新線程3. 建立一個類繼承Handler,調用含有Looper的建構函式 public class MyHandler extends Handler{
Time of Update: 2018-12-06
擷取最佳的LocationProvider,這個最佳是根據條件相對而言滴 //現在先來取得電子裝置中都提供了哪些LocationProvider List<String> providers = locationManager.getAllProvider(); for(Iterator iterator = providers.iterator ; iterator.hasNext()){ String s = (String)iterator.
Time of Update: 2018-12-06
寫:1. 通過getSharedPreferences得到SharedPreferences對象;傳入的第一個參數是string類型的名字,傳入的第二個參數可以為MODE_WORLD_READABLE或者MODE_WORLD_WRITEABLE2. 使用該對象的edit方法得到 SharedPreferences.edit對象3. 可以使用各種put方法,例如是putString傳入資料4. 這裡順便說一下 SimpleDateFormat 類, 以下是例子
Time of Update: 2018-12-06
以下是簡訊廣播接收內容步驟:1. 常見一個接收類,此類繼承 BroadcastReceiver ,需要建立一個action;2. 需要在AndroidManifest中註冊這個接收類(關鍵字receiver)並為action綁定,最後註冊簡訊接收許可權 <receiver android:name="EX06_01_SMSreceiver"> //繼承BroadcastReceiver 的類名 <!--
Time of Update: 2018-12-06
Google的Geocoding服務功能: 1. 查詢某地址的經緯度 2. 查詢某經緯度的具體地址 Android的Geocoding替代品 //根據地址查詢經緯度的網址及其解釋 http://maps.googleapis.com/maps/api/geocode/json?address=SFO&sensor=false
Time of Update: 2018-12-06
第一個程式的: SharedPreferences preferences = getSharedPreferences("count", MODE_WORLD_READABLE);第二個程式的: // 擷取其他程式所對應的 Context Context useCount = createPackageContext("org.crazyit.io", Context.CONTEXT_IGNORE_SECURITY);SharedPreferences prefs =