package yu.bin;import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class poweroff extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button t = (Button) findViewById(R.id.abc);
        t.setOnClickListener(new OnClickListener() {            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent shutdown = new Intent(Intent.ACTION_SHUTDOWN);
                startActivity(shutdown);
            }
        });
    }
}<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="yu.bin"
android:versionCode="1"
android:versionName="1.0">
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
<activity
android:name=".poweroff"
android:label="@string/app_name">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:sharedUserId="android.uid.system"
android:name="android.intent.category.LAUNCHER" /> </intent-filter>
</activity>
</application>
<uses-sdk
android:minSdkVersion="8" />
<uses-permission
android:name="android.intent.action.ACTION_SHUTDOWN" />
</manifest> 02-29 06:57:01.315: ERROR/AndroidRuntime(459): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.ACTION_SHUTDOWN }

解决方案 »

  1.   

    这个ShutDown的intent貌似不对外开发,只能由系统发送...想其他办法吧
      

  2.   

    调用系统自带的 。。  这个Intent是系统发送的 。。System 
      

  3.   

    API没有开放,需要提升为syetem app级别
      

  4.   

    猜一下解决办法,楼主可以试试:
    1.在manifest.xml的manifest字段中加入属性:android:sharedUserId="android.uid.system"
    2.用platform key来对APK进行签名
    3.把签好名的APK放到rom对应的zip文件的system/app目录下。
    4.把手机刷成上面rom。
    经过以上操作可能可以使用android.intent.action.ACTION_SHUTDOWN这个intent来关机我没试验过,猜的。。