[Nexus One Android Development] binaryanomaly:
Hi

I'm trying to write an application that puts my device into sleep since my powerbutton is broken. (Thanks no option to return etc.)

Now when i try to tell my phone to go to sleep using:

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
pm.goToSleep(0);

I'm getting the below error. How can I make it work?

I was told I need to sign the app with the rom key to use such low level system functionality. How can I do that, where can I get the key?

Is this possible for stock rom, CM6?

Thanks for you help

I/ActivityManager( 111): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp.sl33p/.sl33p }
W/ActivityManager( 111): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp.sl33p/.sl33p } from ProcessRecord{4415
cd90 14332:android.process.acore/10068} (pid=14332, uid=10068) requires android.permission.DEVICE_POWER
E/Launcher(14332): Launcher does not have the permission to launch Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp.sl33p/.sl33p }. Make sure
to create a MAIN intent-filter for the corresponding activity or use the exported attribute for this activity.
E/Launcher(14332): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp.sl33p/.sl33p } f
rom ProcessRecord{4415cd90 14332:android.process.acore/10068} (pid=14332, uid=10068) requires android.permission.DEVICE_POWER
E/Launcher(14332): at android.os.Parcel.readException(Parcel.java:1247)
E/Launcher(14332): at android.os.Parcel.readException(Parcel.java:1235)
E/Launcher(14332): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
E/Launcher(14332): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
E/Launcher(14332): at android.app.Activity.startActivityForResult(Activity.java:2817)
E/Launcher(14332): at com.fede.launcher.Launcher.startActivityForResult(Launcher.java:2783)
E/Launcher(14332): at android.app.Activity.startActivity(Activity.java:2923)
E/Launcher(14332): at com.fede.launcher.Launcher.startActivity(Launcher.java:3751)
E/Launcher(14332): at com.fede.launcher.Launcher.startActivitySafely(Launcher.java:3736)
E/Launcher(14332): at com.fede.launcher.AllAppsGridView.onItemClick(AllAppsGridView.java:1096)
E/Launcher(14332): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
E/Launcher(14332): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
E/Launcher(14332): at android.os.Handler.handleCallback(Handler.java:587)
E/Launcher(14332): at android.os.Handler.dispatchMessage(Handler.java:92)
E/Launcher(14332): at android.os.Looper.loop(Looper.java:123)
E/Launcher(14332): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/Launcher(14332): at java.lang.reflect.Method.invokeNative(Native Method)
E/Launcher(14332): at java.lang.reflect.Method.invoke(Method.java:521)
E/Launcher(14332): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/Launcher(14332): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/Launcher(14332): at dalvik.system.NativeStart.main(Native Method)