Skip to content

Latest commit

 

History

History
executable file
·
94 lines (61 loc) · 2.48 KB

mobile_android_misc.md

File metadata and controls

executable file
·
94 lines (61 loc) · 2.48 KB

Misc - Android

MultiDex application compiling

Gradle

ADB command

  • Extract a file: adb pull sdcard/log.file
  • Delete a file: adb shell rm -r sdcard/log.file
  • Cat a file: adb -d shell cat /sdcard/chirpproc.txt

Debugging for multithread app

Put the following code fragment in the beginning of doInBackground:

```android.os.Debug.waitForDebugger();```

Then when you set a breakpoint in that thread; eclipse will find it.

Maven/eclipse compatibility

Source directory difference error. Project Property -> Java Build Path -> Source -> Add Foler /src/main/java -> remove the conflicting one.

Examples

Basic Logging code

	public static void appendlog(String text){
		File logFile = new File("sdcard/log.file");
		if (!logFile.exists())
		{
			try
			{
				logFile.createNewFile();
			} 
			catch (IOException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		try
		{
			//BufferedWriter for performance, true to set append to file flag
			BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true)); 
			buf.append(text);
			buf.newLine();
			buf.close();
		}
		catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}