This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected void onDestroy() { | |
| unregisterReceivers(); | |
| LocationManager.getInstance().unregister(this); | |
| AppState.getInstance().setStateChangeListener(null); | |
| LocalBroadcastManager.getInstance(getApplicationContext()) | |
| .unregisterReceiver(messageReciver); | |
| super.onDestroy(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LoginActivity extends Activity implements LocationListener { | |
| @Override | |
| public void onLocationUpdated(Location location){ | |
| // do something | |
| } | |
| @Override | |
| protected void onStart(){ | |
| LocationManager.getInstance().register(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SingletonManager { | |
| // .... | |
| public synchronized static SingletonManager getInstance(Context context) { | |
| if (singleton == null) { | |
| singleton = new SingletonManager(context.getApplicationContext()); | |
| } | |
| return singleton; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SingletonManager.getInstance(getApplicationContext()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LoginActivity extends Activity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| //... | |
| SingletonManager.getInstance(this); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SingletonManager { | |
| private static SingletonManager singleton; | |
| private Context context; | |
| private SingletonManager(Context context) { | |
| this.context = context; | |
| } | |
| public synchronized static SingletonManager getInstance(Context context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ThreadActivity extends Activity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| //.... | |
| new DownloadTask(this).start(); | |
| } | |
| private class DownloadTask extends Thread { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ThreadActivity extends Activity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| //... | |
| new DownloadTask().start(); | |
| } | |
| private class DownloadTask extends Thread { | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (vibrationPattern !=null && vibrationPattern.lenght > 0){ | |
| this.mVibrationEnabled = true; | |
| this.mVibration = vibrationPattern | |
| }else{ | |
| this.mVibrationEnabled = false; | |
| this.mVibration = null; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static String longArrayToString(long[] values) { | |
| StringBuffer sb = new StringBuffer(); | |
| if (values != null) { | |
| for (int i = 0; i < values.length - 1; i++) { | |
| sb.append(values[i]).append(DELIMITER); | |
| } | |
| sb.append(values[values.length - 1]); | |
| } | |
| return sb.toString(); | |
| } |
NewerOlder