<file_sep>package com.test.bootreceiver;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootBroadcastReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		
		//下面添加 接收到开机完成广播后的要执行的代码
		System.out.println(">>>>>>>>>>>>Boot");
		//开机启动Activity
		Intent it =context.getPackageManager().getLaunchIntentForPackage("com.test.bootreceiver"); 
		context.startActivity(it ); 
		//开机启动Service
		Intent service = new Intent(context,ServiceTest.class);  
        context.startService(service);  
		
	}  
   
  
} <file_sep>package com.example.hellondk;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends Activity {
	TextView textView;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		textView = (TextView)findViewById(R.id.tv);
		
		String str = getText();//调用native方法
		
		textView.setText(str);
		System.out.println(getText2());
	}

	static{
		System.loadLibrary("mylib");//导入链接库
	}
	public native String getText();//声明native方法
	public native String getText2();//声明native方法
}
<file_sep>package com.example.screenshot;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Bundle;
import android.os.Environment;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
/**
 * 屏幕截图
 * @author EPICVIEW
 *
 */
public class MainActivity extends Activity {

	private Button btn1;
	private String fileName;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		btn1 = (Button)findViewById(R.id.button1);
		btn1.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				GetandSaveCurrentImage() ;
			}
		});
	}

/**
     * 获取和保存当前屏幕的截图
     */
    private void GetandSaveCurrentImage()  
    {  
        //1.构建Bitmap  
        WindowManager windowManager = getWindowManager();  
        Display display = windowManager.getDefaultDisplay();  
        int w = display.getWidth();  
        int h = display.getHeight();  

        Bitmap Bmp = Bitmap.createBitmap( w, h, Config.ARGB_8888 );      

        //2.获取屏幕  
        View decorview = this.getWindow().getDecorView();   
        decorview.setDrawingCacheEnabled(true);   
        Bmp = decorview.getDrawingCache();   

        String SavePath = getSDCardPath()+"/ScreenImage";

        //3.保存Bitmap   
        try {  
            File path = new File(SavePath);  
            //文件  
            fileName  =new  java.text.SimpleDateFormat("yyyyMMddhhmmss").format(new java.util.Date());
            String filepath = SavePath + "/"+fileName+".png";  
            File file = new File(filepath);  
            if(!path.exists()){  
                path.mkdirs();  
            }  
            if (!file.exists()) {  
                file.createNewFile();  
            }  

            FileOutputStream fos = null;  
            fos = new FileOutputStream(file);  
            if (null != fos) {  
                Bmp.compress(Bitmap.CompressFormat.PNG, 90, fos);  
                fos.flush();  
                fos.close();    
                Toast.makeText(this, "截屏文件已保存至SDCard/ScreenImage/"+fileName+".png", Toast.LENGTH_LONG).show();  
            }  

        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  

    /**
     * 获取SDCard的目录路径功能
     * @return
     */
    private String getSDCardPath(){
        File sdcardDir = null;
        //判断SDCard是否存在
        boolean sdcardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
        if(sdcardExist){
            sdcardDir = Environment.getExternalStorageDirectory();
        }
        return sdcardDir.toString();
    }

}
<file_sep>#include<string.h>
#include<stdio.h>
#include<jni.h>
jstring
Java_com_example_hellondk_MainActivity_getText(JNIEnv* env,jobject obj)
{
	return(*env)->NewStringUTF(env,"Hello NDK");
}
Java_com_example_hellondk_MainActivity_getText2(JNIEnv* env,jobject obj)
{
	return(*env)->NewStringUTF(env,"Hello NDK2");
}
<file_sep>package com.example.android3d;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.WindowManager;

public class MainActivity extends Activity {

	 public void onCreate(Bundle savedInstanceState) {
		 
	        super.onCreate(savedInstanceState);
	 
	        CoverFlow cf = new CoverFlow(this);
	 
	 
	        //cf.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.bg));//±³¾°
	 
	        cf.setAdapter(new ImageAdapter(this));
	 
	        ImageAdapter imageAdapter = new ImageAdapter(this);
	 
	        cf.setAdapter(imageAdapter);
	 
	        cf.setSelection(2, true);
	 
	        cf.setAnimationDuration(1000);
	 
	        setContentView(cf);
	 
	    }

}
<file_sep>package com.example.hellondk;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends Activity {
	TextView textView;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		textView = (TextView) findViewById(R.id.tv);

		String str = getText();// 调用native方法

		textView.setText(str + "\n" + getText2() + "\n" + getText3() + "\n"
				+ AddInt(1, 2) + "\n" + getInt() + "\n" + calc());
	}

	static {
		System.loadLibrary("mylib");// 导入链接库
	}

	public native String getText();// 声明native方法

	public native String getText2();// 声明native方法

	public native String getText3();// 声明native方法

	public native int getInt();

	public native int AddInt(int a, int b);// 声明native方法

	public native int calc();
}
<file_sep>#include<string.h>
#include<stdio.h>
#include<jni.h>
jstring Java_com_example_hellondk_MainActivity_getText(JNIEnv* env,jobject obj)
{
	return(*env)->NewStringUTF(env," Hello NDK-1");
}
jstring Java_com_example_hellondk_MainActivity_getText2(JNIEnv* env,jobject obj)
{
	return(*env)->NewStringUTF(env," Hello NDK-2");
}
jstring Java_com_example_hellondk_MainActivity_getText3(JNIEnv* env,jobject obj)
{
	return(*env)->NewStringUTF(env," Hello NDK-3");
}
jint Java_com_example_hellondk_MainActivity_getInt(JNIEnv* env,jobject obj)
{
	return 1;
}
JNIEXPORT jint JNICALL Java_com_example_hellondk_MainActivity_AddInt
  (JNIEnv *env, jclass arg, jint a, jint b)
{
    return a + b;
}

<file_sep>#include<string.h>
#include<stdio.h>
#include<jni.h>

jint Java_com_example_hellondk_MainActivity_calc()
{
	return 1;
}
<file_sep>package com.example.senor;

import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
/**
 * 功能：获取手机的方向
 * 描述：使用官方推荐的方法getOrientation(x,x)代替,getDefaultSensor(Sensor.TYPE_ORIENTATION)
 * 		 通过加磁力计magnetometer和加速度传感器accelerometer的值计算出方向值
 * 		 具体参考http://blog.csdn.net/android_qhdxuan/article/details/7454313
 * @author EPICVIEW
 *
 */
public class MainActivity extends Activity {
	
    /** Called when the activity is first created. */
	TextView tv1,tv2,tv3;
	private SensorManager sm=null;
	private Sensor aSensor=null;
	private Sensor mSensor=null;
	 
	float[] accelerometerValues=new float[3];
	float[] magneticFieldValues=new float[3];
	float[] values=new float[3];
	float[] rotate=new float[9];
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv1=(TextView)findViewById(R.id.t1);
        tv2=(TextView)findViewById(R.id.t2);
        tv3=(TextView)findViewById(R.id.t3);
        sm=(SensorManager)getSystemService(Context.SENSOR_SERVICE);
        aSensor=sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        mSensor=sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
        sm.registerListener(myListener, aSensor, SensorManager.SENSOR_DELAY_GAME);
        sm.registerListener(myListener, mSensor, SensorManager.SENSOR_DELAY_GAME);
        
        
    }

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		sm.unregisterListener(myListener);
	}
	final SensorEventListener myListener=new SensorEventListener(){

		@Override
		public void onAccuracyChanged(Sensor sensor, int accuracy) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void onSensorChanged(SensorEvent event) {
			// TODO Auto-generated method stub
			if(event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
				accelerometerValues=event.values;
			}
			if(event.sensor.getType()==Sensor.TYPE_MAGNETIC_FIELD){
				magneticFieldValues=event.values;
			}
			
			SensorManager.getRotationMatrix(rotate, null, accelerometerValues, magneticFieldValues);
			SensorManager.getOrientation(rotate, values);
			//经过SensorManager.getOrientation(rotate, values);得到的values值为弧度
			//转换为角度
			values[0]=(float)Math.toDegrees(values[0]);
			values[1]=(float)Math.toDegrees(values[1]);
			values[2]=(float)Math.toDegrees(values[2]);
			tv1.setText("x="+(int )values[0]);
			tv2.setText("y="+(int )values[1]);
			tv3.setText("z="+(int )values[2]);
		}};
		
	
    
}<file_sep>LOCAL_PATH	:=$(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE	:=mylib
LOCAL_SRC_FILES	:=source.c calc.c	

include $(BUILD_SHARED_LIBRARY)