2012년 1월 10일 화요일

Android 참고할 소스 Keyword(2012. 01. 10)

** 1 **
http://lwn.net/
http://www.kandroid.org/board/board.php?board=androidsource&command=body&no=82

** 2 **

CompoundButton
ProgressDialog
progressDialog.setView(view)
ProgressBar

file.canRead()

        addPreferencesFromResource(R.xml.preferences);
        togglePreference = (TogglePreference) getPreferenceManager().findPreference(ApplicationConstants.SETTINGS_TOGGLE_BUTTON);


Log.isLoggable(TAG, Log.VERBOSE)

ConnManagerParams.setTimeout(params, REGISTRATION_TIMEOUT);

DateUtils.SECOND_IN_MILLIS

** 3 **


MainActivity.java
        // Init Application
        this.application = (TetherApplication)this.getApplication();
        MainActivity.setCurrent(this);
TetherApplication.java
        // Whitelist
        this.whitelist = this.coretask.new Whitelist();
class DnsUpdate implements Runnable {

    String[] dns;
   
    public DnsUpdate(String[] dns) {
    this.dns = dns;
    }
   
public void run() {
           while (!Thread.currentThread().isInterrupted()) {
            String[] currentDns = TetherApplication.this.coretask.getCurrentDns();
            if (this.dns == null || this.dns[0].equals(currentDns[0]) == false || this.dns[1].equals(currentDns[1]) == false) {
            this.dns = TetherApplication.this.coretask.updateResolvConf();
            }
               // Taking a nap
      try {
    Thread.sleep(10000);
    } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    }
           }
}
   }  


   <uses-permission
        android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission
        android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <uses-permission
        android:name="android.permission.READ_CONTACTS" />
    <uses-permission
        android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission
        android:name="android.permission.READ_SYNC_STATS" />
    <uses-permission
        android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission
        android:name="android.permission.WRITE_SYNC_SETTINGS" />


 public static Thread performOnBackgroundThread(final Runnable runnable) {
        final Thread t = new Thread() {
            @Override
            public void run() {
                try {
                    runnable.run();
                } finally {

                }
            }
        };
        t.start();
        return t;
    }

    @Override
    public final void onHandleIntent(Intent intent) {
        try {
            Context context = getApplicationContext();
            if (intent.getAction().equals(REGISTRATION_CALLBACK_INTENT)) {
                handleRegistration(context, intent);
            } else if (intent.getAction().equals(C2DM_INTENT)) {
                onMessage(context, intent);
            } else if (intent.getAction().equals(C2DM_RETRY)) {
                C2DMessaging.register(context, senderId);
            }
        } finally {
            //  Release the power lock, so phone can get back to sleep.
            // The lock is reference counted by default, so multiple
            // messages are ok.
           
            // If the onMessage() needs to spawn a thread or do something else,
            // it should use it's own lock.
            mWakeLock.release();
        }
    }

댓글 없음:

댓글 쓰기