目前日期文章:201211 (5)

瀏覽方式: 標題列表 簡短摘要

程式執行當中常常需要記錄各種資訊,如果需要處理的資訊較為單純,可以直接使用文字檔來紀錄,假若資料較繁雜就需要用SQLite,在此先以簡單文字檔做切入,先以Java I/O介紹寫檔、讀檔常用的方法及常用的Method

 

Chi Learning 發表在 痞客邦 PIXNET 留言(0) 人氣()

首先是從BroadcastReceiver派生出一個新類,用來監聽系統啟動後發出的廣播消息android.intent.action.BOOT_COMPLETED  

  • BootReceiver.java:
  • import android.content.BroadcastReceiver;
  • import android.content.Context;
  • import android.content.Intent;
  • import android.util.Log;
  • publicclass BootReceiver extends BroadcastReceiver {
  • publicvoid onReceive(Context context, Intent intent) {
  • if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
  • {
  • Log.d("BootReceiver", "system boot completed");
  • Intent newIntent = new Intent(context, FirstRun.class);
  • newIntent.setAction("android.intent.action.MAIN"); //MyActivity action defined in AndroidManifest.xml
  • newIntent.addCategory("android.intent.category.LAUNCHER");//MyActivity category defined in AndroidManifest.xml
  • newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //If activity is not launched in Activity environment, this flag is mandatory to set
  • context.startActivity(newIntent);
  • //if you want to start a service, follow below method:
  • /*******************************************************
  • Intent service = new Intent(yourService.ACTION_START);
  • service.setClass(context, yourService.class);
  • context.startService(service);
  • ******************************************************/
  • }
  • }
  • }

接下来这个类就是监听到系统启动完毕后,我们要运行的activity.

Chi Learning 發表在 痞客邦 PIXNET 留言(0) 人氣()

I had reported earlier how I had gotten a C Hello World statically-linked program running on my Android phone using CodeSourcery's toolchain (on linux). Today I got a dynamically-linked Hello World program running on the phone, compiled using Android's prebuilt toolchain from the source.

Chi Learning 發表在 痞客邦 PIXNET 留言(0) 人氣()

入門 Android,安裝了一堆有的沒的之後  

新增一個Project執行,卻出現

Chi Learning 發表在 痞客邦 PIXNET 留言(0) 人氣()

Hello World in C on Android

If you've been following the Android world, you'd know that Android's SDK requires you to write apps in Java. Ever since I got my phone I've been dying to run a Hello World C program, but I've been unable to get the right cross compiler for it.

Chi Learning 發表在 痞客邦 PIXNET 留言(0) 人氣()

找更多相關文章與討論