首页 技术 正文
技术 2022年11月15日
0 收藏 540 点赞 2,234 浏览 4015 个字

1、cygwin环境变量设置

可在Cygwin.bat 中设置

set NDK_ROOT=P:/android/android-ndk-r8e

或者在home\Administrator\.bash_profile中设置

NDK_ROOT=/cygdrive/p/android/android-ndk-r8e
export NDK_ROOT

或者在运行程序前设置(绿色方式)

setlocal enabledelayedexpansion
set NDK_ROOT=%cd%\android-ndk-r8e
start %cd%\adt-bundle-windows-x86-20130522\eclipse\eclipse.exe

NDK与eclipse在同一级目录下。

2、Android 属性相关

<application android:icon=”@drawable/icon”//应用安装后桌面显示的图标

android:label=”@string/app_name”>

<activity android:name=”.FormulaStudy” android:theme=”@android:style/Theme.NoTitleBar” //无标题
android:screenOrientation=”sensorLandscape” //只允许横屏切换
android:label=”@string/app_name”>

<intent-filter>

<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” /> //第一个Activity
</intent-filter>
</activity>
<uses-library android:name=”com.noahedu”/>

<uses-sdk android:minSdkVersion=”4″ android:targetSdkVersion=”10″/>
<uses-permission android:name=”com.noahedu.permission.AWARD_SCORE”/>

</application>

3、Shell多行注释

: :||:<<\COMMENTS

注释内容

COMMENTS

4、SourceInsight配置

AStyle格式化工具: 在Command增加AStyle,在Run填写”~\AStyle.exe” –style=linux -s4 -S -N -L -m0 -M40 –suffix=none –convert-tabs %f,再配置快捷键

TabSiPlus外挂式的文件标签,下载后运行后再执行sourceinsight主程序

3、定时操作

Handler mHandler = new Handler();

mHandler.postDelayed(new Runnable()
{
@Override
public void run()
{
}
}, 3000);

4、TagSoup 是一个Java开发符合SAX的HTML解析器

5、android-ndk-r8e/build/gmsl/__gmsl:512: *** non-numeric second argument to `wordlist’ function: ”.

将AndroidManifest.xml文件先移动到其他地方,编译成功后再mv回来,这样操作果然成功。

6、

程序主动触发系统回收资源
System.runFinalization();
System.gc();
进程真正退出
System.exit(0);

1.不需要后台运行的app需在退出时调用上面的代码,以便系统回收资源和进程真正退出
2.app运行过程中也可以在合适的时候主动触发系统回收资源

基本上是Activity退到后台时加入以下一段代码处理
if (isTaskRoot()) {
System.runFinalization();
System.gc();
System.exit(0);
}

7、退出所有Activity的方法

在BaseActivity类中

private static LinkedList<Activity> activityList = new LinkedList<Activity>();

在onCreate中activityList.add(this);每次进入新的Activity将this指针压入链表,

重写onDestroy()方法移除相应的Activity,activityList.remove(this);

退出所有的Activity时,只要调用finish();方法,并移除所有的Activity就可以了。

8、android系统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

注意函数名称命名方式。

java|包名|类名称|函数名称

Java_com_noahedu_dataparser_ImageDecoder_decode

9、jni调试

//在C工程、android工程 调试切换
#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杂记

jstring path

const char *file = (*env)->GetStringUTFChars(env, path, NULL);

(*env)->ReleaseStringUTFChars(env, path, file);

11、取消代码混淆编译

LOCAL_PROGUARD_ENABLED := disabled

12、使用jar包名称区分大小写

<uses-library
android:name=”PenWriterLib”
android:required=”false” />

13、listview背景黑块问题

android:cacheColorHint=”#00000000″

12、在android程序中,如何将LogCat上的日志输出到文件?

LogCat存储在circular memory buffers中。

(1)、可以通过命令来导出Log:

引用adb logcat -d > logcat.txt

详细参考 
http://developer.android.com/tools/help/adb.html#logcat

(2)、在程序中获取Log的方法:

引用<uses-permission android:name=”android.permission.READ_LOGS” />

  1. public class LogTest extends Activity {
  2. @Override
  3. public void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. setContentView(R.layout.main);
  6. try {
  7. Process process = Runtime.getRuntime().exec(“logcat -d”);
  8. BufferedReader bufferedReader = new BufferedReader(
  9. new InputStreamReader(process.getInputStream()));
  10. StringBuilder log=new StringBuilder();
  11. String line;
  12. while ((line = bufferedReader.readLine()) != null) {
  13. log.append(line);
  14. }
  15. TextView tv = (TextView)findViewById(R.id.textView1);
  16. tv.setText(log.toString());
  17. } catch (IOException e) {
  18. }
  19. }
  20. }

详细参考 
http://www.helloandroid.com/tutorials/reading-logs-programatically

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,090
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,567
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,415
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,187
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,823
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,906