Time of Update: 2013-12-10
在前文Android定位功能(一)中,已經大致介紹了一下在Android平台中,和定位功能相關的類,並舉例擷取了位置資訊。但是前文是基於Criteria定製了一個標準,通過getBestProvider()方法由Android系統自動擷取最符合Criteria的LocationProvider,從而實現了定位功能。這樣的做法能最大限度的保證定位功能的可實現性,但是卻無法保證擷取到的位置資訊有最大的準確度。因為除了GPS外,其他定位方式都或多或少存在著位置位移。 在實現GPS定位前,先瞭解一下G
Time of Update: 2013-12-10
系統內建的Theme:--------------------------------------------------------------------------------android以及為我們定義好了一些theme,需要是我們直接可以拿來使用。常用的Theme通常如下: android:theme="@android:style/Theme.Dialog"將一個activity顯示為對話方塊模式 android:theme=&qu
Time of Update: 2013-12-10
我們只需要重寫子viewpager 就可以很好的解決這個問題了 /** * ChanpinViewPager.java * com.stg.ln.utils.ui * * Function: TODO * * ver date
Time of Update: 2013-12-10
URL的openConnection方法將返回一個URLConnection,該對象表示應用程式和URL之間的通訊串連。程式可以通過它的執行個體向該URL發送請求,讀取URL引用的資源。下面通過一個簡單樣本來示範:Activity: package com.home.urlconnection; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection;
Time of Update: 2013-12-10
網路操作是進行網路通訊的安卓程式必不可少的一個重要部分,Android平台有三種網路介面可以使用,他們分別是:java.net.*(標準Java介面)、Org.apache HttpComponents介面和Android.net.*(Android網路介面)。當然還可以使用瀏覽器webkit來進行網路訪問等。其中,前兩個介面可以用來進行http、socket通訊,後一個介面主要是用來判斷安卓裝置網路連接狀況的。所以,本節重點說一下前兩個介面。 1、java.
Time of Update: 2013-12-10
方法一 Timer與TimerTask(Java實現) [java] view plaincopyprint? public class timerTask extends Activity{ private int recLen = 11; private TextView txtView; Timer timer =
Time of Update: 2013-12-10
有人說聲明 Private Destructor, 這對象只能在 stack 上建立,不能在Heap上建立, 其實錯了, 這樣的程式編譯都過不了. 那為何會有 Private Destructor, 因為程式是這樣寫的 ------------------------------------class Base {public: Base();protected: virtual ~Base();
Time of Update: 2013-12-10
本文要做的事情就是在前面做的簡單的ToDoList程式上增加一個配置項頁面(Reference)。這個Reference頁面也非常簡單:
Time of Update: 2013-12-10
public class ResizeLayout extends FrameLayout { private OnkeyboardShowListener mChangedListener; private boolean misKeyboardshow = false; private RRSharedPreferences preferences; private int keyboardHeight =
Time of Update: 2013-12-10
屏蔽返回鍵的代碼:public boolean onKeyDown(int keyCode,KeyEvent event){switch(keyCode){case KeyEvent.KEYCODE_HOME:return true;case KeyEvent.KEYCODE_BACK:return true;case KeyEvent.KEYCODE_CALL:return true;case KeyEvent.KEYCODE_SYM: return true;case
Time of Update: 2013-12-10
前幾天做一個小應用,需要用到在service中調用Activity, 但是發現總是出現ANR,百度了下,發現各種說法,不過經過嘗試,發現問題不大,只需要加一句代碼就足夠了,代碼如下: public class XXXService extends Service { public void onCreate() { super.onCreate(); //撥打到電話 Intent call = new Intent(&
Time of Update: 2013-12-10
private void toExecuteSave(){ Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType("vnd.android.cursor.dir/person"); intent.setType("vnd.android.cursor.dir/contact");
Time of Update: 2013-12-10
package com.example.html5_chart;public class Contact {private String name;private double value;private String color;public Contact(String name, double value, String color) {super();this.name = name;this.value = value;this.color = color;}public
Time of Update: 2013-12-10
import android.annotation.SuppressLint;import android.content.Context;import android.view.View;import android.widget.Toast;public class ToastUtil {private static Toast toast;private static View view;private ToastUtil()
Time of Update: 2013-12-10
最近在做一個項目,要求實現上下能滾動,每項能左右滾動,最後效果是實現了,可資料的通訊可能有點麻煩,暫時又被砍掉了,先放上來存檔,轉載請註明出處,謝謝代碼如下 public class GroupActivity extends Activity { private List<TeamBean> gbList;// private MyListAdapter adapter; private ItemClickEvent listener;//
Time of Update: 2013-12-10
1 xml <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
Time of Update: 2013-12-10
筆者最近開始淪陷於android,從開始入門到現在已經快半個月的時間,於是便寫一個較綜合,用到了資料庫,多線程操作,以及時鐘的添加和停止消除,activity之間的動畫轉換等,適用於初學者學以致用的小遊戲來鞏固自己的知識,有需要的讀者可以去我的資產庫中下載源碼。 以下是主遊戲程式的部分代碼,帶有筆者的豐富注釋: package com.example.pingping_game1;import java.util.HashMap;import
Time of Update: 2013-12-10
ImageView沒有邊角圓化的設定,但是可以通過代碼設定實現。一個國外的碼農寫的方法。 package com.example.roundrectshader; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import
Time of Update: 2013-12-10
package cc.testservice2;import android.app.Activity;import android.content.ComponentName;import android.content.Intent;import android.content.ServiceConnection;import android.os.Bundle;import android.os.IBinder;import android.view.View;import
Time of Update: 2013-12-10
最近做項目需要一個拍照後,將圖片上傳到伺服器的功能,並且伺服器是cs的webservice寫的,通常我們調用webservcie通訊都是傳遞xml或者json格式的字串。從來沒傳過圖片這樣的檔案。百度了很多方法,最後使用了從android端用io流讀取到要上傳的圖片,用Base64編碼成位元組流的字串,通過調用webservice把該字串作為參數傳到伺服器端,服務端解碼該字串,最後儲存到相應的路徑下。整個上傳過程的關鍵就是 以 位元組流的字串