1. Cygwin environment variable setting
Can be set in Cygwin.bat
Set ndk_root=p:/android/android-ndk-r8e
or set in Home\administrator\.bash_profile
ndk_root=/cygdrive/p/android/android-ndk-r8e
Export Ndk_root
or set before running the program (green mode)
Setlocal enabledelayedexpansion
Set ndk_root=%cd%\android-ndk-r8e
Start%cd%\adt-bundle-windows-x86-20130522\eclipse\eclipse.exe
The NDK and eclipse are in the same level directory.
2, Android Properties related
<application android:icon= "@drawable/icon"//icon for desktop display after application installation
Android:label= "@string/app_name" >
<activity android:name= ". Formulastudy "Android:theme=" @android: Style/theme.notitlebar "//Untitled
android:screenorientation= "Sensorlandscape"//allow only horizontal screen switching
Android:label= "@string/app_name" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>//First activity
</intent-filter>
</activity>
<uses-library android:name= "com.noahedu"/>
<USES-SDK android:minsdkversion= "4" android:targetsdkversion= "Ten"/>
<uses-permission android:name= "Com.noahedu.permission.AWARD_SCORE"/>
</application>
3, Shell multi-line Comment
:: | |:<<\comments
Comment Content
COMMENTS
4. Sourceinsight Configuration
Astyle formatting tool: Add Astyle in command, fill "~\astyle.exe"--style=linux-s4-s-n-l-m0-m40--suffix=none--convert-tabs%f in run, and match Reset shortcut keys
Tabsiplus plug-in file label, after downloading and then run the Sourceinsight main program
3. Timed operation
Handler Mhandler = new Handler ();
Mhandler.postdelayed (New Runnable ()
{
@Override
public void Run ()
{
}
}, 3000);
4,Tagsoup is a Java development of SAX-compliant HTML parser
5, android-ndk-r8e/build/gmsl/__gmsl:512: * * * non-numeric second argument to ' wordlist ' function: '.
Move the Androidmanifest.xml file to a different place first, and then MV back after the successful compilation, so the operation is successful.
6.
The program actively triggers the system to recycle resources
System.runfinalization ();
System.GC ();
Process really quits
System.exit (0);
1. Apps that do not need to run in the background should invoke the above code on exit so that the system reclaims the resources and the process really exits
2.app can also actively trigger the system to recycle resources at the right time during the operation.
Basically, when the activity is back in the background, add the following code processing
if (Istaskroot ()) {
System.runfinalization ();
System.GC ();
System.exit (0);
}
7. How to exit all activity
In the Baseactivity class
private static linkedlist<activity> activitylist = new linkedlist<activity> ();
Activitylist.add (this) in OnCreate, and each time it enters a new activity, it presses the this pointer into the linked list,
Override the OnDestroy () method to remove the corresponding activity,activitylist.remove (this);
When you exit all activity, just call the finish () method and remove all activity.
8. Example of an Android system JNI
public class Imagedecoder {
static{
System.loadlibrary ("Mathappliedprodec");
}
Public native Boolean decode (String path, Bitmap Bitmap, int imageType);
Public native Boolean encode (String path, Bitmap Bitmap, int imageType);
}
#include <jni.h>
#ifndef _included_com_noahedu_dataparser_imagedecoder
#define _included_com_noahedu_dataparser_imagedecoder
#ifdef __cplusplus
extern "C" {
#endif
Jniexport Jboolean Jnicall Java_com_noahedu_dataparser_imagedecoder_decode
(JNIEnv *, Jobject, jstring, Jobject, Jint);
Jniexport Jboolean Jnicall Java_com_noahedu_dataparser_imagedecoder_encode
(JNIEnv *, Jobject, jstring, Jobject, Jint);
#ifdef __cplusplus
}
#endif
#endif
Notice how the function names are named.
Java| Package name | class name | function name
Java_com_noahedu_dataparser_imagedecoder_decode
9. JNI Debugging
In C Engineering, Android Engineering debug switch
#ifdef ANDROID
#include <android/log.h>
#define LOG_TAG "Mathapplied"
#define Logi (...) __android_log_print (Android_log_info, Log_tag, __va_args__)
#else
#define Logi (...) printf (__va_args__);
#endif
10. JNI Essays
Jstring Path
const char *file = (*env)->getstringutfchars (env, Path, NULL);
(*env)->releasestringutfchars (env, path, file);
11. Cancel code Obfuscation compilation
local_proguard_enabled: = disabled
12. Case sensitivity using JAR package name
<uses-library
Android:name= "Penwriterlib"
Android:required= "false"/>
13, the ListView background black block problem
Android:cachecolorhint= "#00000000"
12, in the Android program, how to output the log on the logcat to a file?
The logcat is stored in the circular memory buffers.
(1), you can export log by command:
cite adb logcat-d > Logcat.txt
Detailed reference
Http://developer.android.com/tools/help/adb.html#logcat
(2), the method of obtaining log in the program:
Reference <uses-permission android:name= "Android.permission.READ_LOGS"/>
Java code
- Public class Logtest extends Activity {
- @Override
- public void OnCreate (Bundle savedinstancestate) {
- super.oncreate (savedinstancestate);
- Setcontentview (R.layout.main);
- try {
- Process process = Runtime.getruntime (). EXEC ("logcat-d");
- BufferedReader BufferedReader = new BufferedReader (
- New InputStreamReader (Process.getinputstream ()));
- StringBuilder log=New StringBuilder ();
- String Line;
- While (line = Bufferedreader.readline ()) = null) {
- Log.append (line);
- }
- TextView TV = (TextView) Findviewbyid (R.ID.TEXTVIEW1);
- Tv.settext (Log.tostring ());
- } catch (IOException e) {
- }
- }
- }
Detailed reference
Http://www.helloandroid.com/tutorials/reading-logs-programatically