Time of Update: 2018-12-03
以前一直以為service是一個背景程式,其實不是,service只是一個沒有介面的activity而已,耗時的操作如果放在onstart裡面一樣會拋出ANR(沒有響應)錯誤,並且如果想要一直在後台跑,必須使用alarmmanager每隔幾分鐘喚醒一次裝置才行,否則過一段時間裝置進入sleep則自動關閉掉service了一個比較靠譜的辦法是alarmmanager結合intentservice來達到,因為intentservice是在非UI線程來執行裡面的onhandleintent函數的
Time of Update: 2018-12-03
參考文檔:http://linux.chinaunix.net/techdoc/beginner/2009/02/06/1060906.shtml運行環境:Ubuntu8.101、構建交叉編譯環境Android的預設硬體處理器是ARM的,因此我們需要在自己的host機器上構建交叉編譯環境。來到CodeSourcery,(http://www.codesourcery.com/gnu_toolchains/arm/download.html),點擊GNU/Linux對應的連結,再點擊IA32
Time of Update: 2018-12-03
public class HelloanActivity extends Activity implements View.OnClickListener,SensorEventListener{ImageView imageView = null;private SensorManager mSensorManager = null; private Sensor mSensor = null; private float x,y,z; private Handler
Time of Update: 2018-12-03
隨著對Drewable的深入瞭解,發現了Drawable更加強大的功能:顯示Animation。Android SDK介紹了2種Animation:Tween Animation:通過對情境裡的對象不斷做映像變換(平移、縮放、旋轉)產生動畫效果 Frame Animation:順序播放事先做好的映像,跟電影類似 在使用Animation前,我們先學習如何定義Animation,這對我們使用Animation會有很大的協助。Animation是以 XML格式定義的,定義好的XML檔案存放在res/
Time of Update: 2018-12-03
許多初次接觸Android開發的朋友會遇到調試的問題,如何能夠根據錯誤提示迅速的找到“出事地點呢”?在Eclipse+ADT的開發環境中沒有好的直接跟蹤對象內容的方法,通過使用android.util.Log類可以協助你自己尋找錯誤和列印系統日誌訊息。它是一個進行日誌輸出的API,我們在Android 程式中可以隨時為某一個對象插入一個Log,然後在DDMS中觀察Logcat的輸出是否正常。android.util.Log常用的方法有以下5個:Log.v() Log.d() Log.i()
Time of Update: 2018-12-03
前幾天老闆跟我說為何我們不把某個產品賣給別人,看了這篇文章,理解了。http://www.36kr.com/p/44964.htmlGartner最新報告稱Android手機以近2:1的優勢在出貨量方面超過了iPhone,Google肯定在慶祝。鑒於蘋果的市場領先地位,Android的確很了不起。但Google或許對自己過去所採取的戰略感到後悔。為了“獲勝”,Google組建並訓練了一支由硬體廠商組成的僱傭軍,誰出的價格高,他們就跟誰合作,不管是Google、百度還是Bing。毫無疑問Googl
Time of Update: 2018-12-03
http://www.cnblogs.com/playing/archive/2011/03/18/1988182.html EditText: 通常用於顯示文字,但有時候也需要在文字中夾雜一些圖片,比如QQ中就可以使用表情圖片,又比如需要的文字高亮顯示等等,如何在android中也做到這樣呢? 記得android中有個android.text包,這裡提供了對文本的強大的處理功能。 添加圖片主要用SpannableString和ImageSpan類: Drawable
Time of Update: 2018-12-03
l1;mso-kinsoku-overflow:1'>宋體;mso-hansi-font-family:Arial;font-size:14pt;mso-fareast-language:ZH-CN"> px (pixels)font-size:14pt">像素Arial;font-size:14pt">
Time of Update: 2018-12-03
轉;http://wang-peng1.iteye.com/blog/523869在GradientDrawable1試圖中終於把shape學會了,以前總是似懂非懂,現在終於把裡面的東西搞清楚了,同時也挺佩服Google的用心,故意設定一些陷阱吧,不認真對待還真以為沒有啥效果呢。 setContentView(R.layout.shape_drawable_1) shape_drawable_1 代碼如下: <ScrollView
Time of Update: 2018-12-03
public static interfaceGLSurfaceView.Rendererandroid.opengl.GLSurfaceView.RendererClass OverviewA generic renderer interface. 是一個一般的渲染類介面 The renderer is responsible for making OpenGL calls to render a frame.這個renderer類負責
Time of Update: 2018-12-03
一. 監聽和判斷網路狀態(轉貼:http://wang-peng1.javaeye.com/blog/557362):public class ConnectionChangeReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { ConnectivityManager connectivityManager =
Time of Update: 2018-12-03
和以前不同,這次只放代碼,不再寫步驟,但是,養成一個好的書寫步驟是很有必要的,這樣你就不容易出錯,也容易通過你的步驟來找出錯誤。特別是你在C/C++代碼中出錯的時候。 Android.mk: LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE := nativeLOCAL_SRC_FILES := myNative.cinclude
Time of Update: 2018-12-03
NeighboringCellInfo.aidlpackage android.telephony;parcelable NeighboringCellInfo; ITelephony.aidl/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file
Time of Update: 2018-12-03
將js的api文檔整合到android項目中,簡單而且實用。這個時候,你就可以不再用原生態的UI了。通過HTML + JS +css 你可以做出各種各樣的UI 需要注意到是,用這種方式開發程式,軟體的運行效率會比原生態UI慢,但是UI介面更加美觀和靈活變動。第一步: 到http://jquerymobile.com/ 下載最新的 JQuery 的API
Time of Update: 2018-12-03
第一步:運行cygwin,進入到NDK目錄下中的hello-jni項目中,D:/geolo/android-ndk-r4b/samples/hello-jni第二步:在cygwin中運行 $NDKROOT/ndk-build 命令,這次會對hello-jni目錄的jni檔案夾裡的 C 檔案進行編譯。 最後會在路徑D:/geolo/android-ndk-r4b/samples/hello-jni/libs/armeabi中產生 原生態的C/C++庫第三步:
Time of Update: 2018-12-03
Ubuntu下尋找avd 1. 終端執行 zhihui@zhihui:/$ sudo find -name avd [sudo] password for zhihui: 會列出檔案: ./home/zhihui/.android/avd 2. linux下帶點檔案名稱的都會自動隱藏,如.android/avd 使用 ls -al可看到該目錄下所有檔案 zhihui@zhihui:~$ ls -al
Time of Update: 2018-12-03
Android PDF 閱讀器 http://sourceforge.net/projects/andpdf/files/個人記賬工具 OnMyMeans http://sourceforge.net/projects/onmymeans/developAndroid電池監控 Android Battery Dog http://sourceforge.net/projects/andbatdog/RSS閱讀軟體 Android RSS
Time of Update: 2018-12-03
res/layout/main.xml檔案內容如下:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"
Time of Update: 2018-12-03
HelloWorldActivity.javapackage syit.david;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import
Time of Update: 2018-12-03
反射是一個好東東,尤其是在與資料庫打交道的時候。 如果沒有現成的資料對應架構,要與大量的資料表打交道的話,技術含量就是與一個表打交道的那麼多技術,可是要是有幾十個資料表的話,就會很費勁來了,不用思考,直接的複製 粘貼 ,耗費時間不說,而且還有耗費咱們的精力和感情,既然都差不多為什麼不讓程式自己去重複呢?我剛才就遇到這個問題了,我想這是可以做到的,於是乎就嘗試這座了一下,一下只是一個雛形,不過已經能基本解決我的問題了。我是一個碼農,我瞭解碼農的心情,來吧,看碼:/*** *