pfillion Member Licensed User Longtime User Jul 3, 2013 #1 Hi, I needed to make the device go to sleep in 15 seconds and wanted to save the current user timeout value and set it to 15 seconds when the user ran my application and restore the initial value when he closed my application. I did not find any library to do it so I wrote my first library to change system settings and it works great with SETTING_SCREEN_OFF_TIMEOUT = "screen_off_timeout". Then I tried to test my library and change the ACTION_AIRPLANE_MODE_CHANGED As String = "android.intent.action.AIRPLANE_MODE". I can toggle the airplane mode but need to intent the OS to let it know that air plane mode has changed. When I do the following code in my library it works fine; Code: Copy Intent intent = new Intent("android.intent.action.AIRPLANE_MODE"); intent.putExtra("state", 1); pBA.context.sendBroadcast(intent); but I did not find a way to do it with the intent function of A4B. Code: Copy Dim Intent1 As Intent Intent1.Initialize(Intent1.ACTION_CALL, "android.intent.action.AIRPLANE_MODE") Intent1.PutExtra("state",1) StartActivity(Intent1) or Code: Copy Dim Intent1 As Intent Intent1.Initialize("android.intent.action.AIRPLANE_MODE","") Intent1.PutExtra("state",1) StartActivity(Intent1) or any other alternative I tried I get the error android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.AIRPLANE_MODE flg=0x20000 (has extras) } Anyone has a clue what I'm doing wrong ? Note: Maybe there is another way to change the airplane mode but I just wanted to test my library and know how to make it work for all the other system settings that I may want to change... without recoding the intent functions to make it work... Thanks
Hi, I needed to make the device go to sleep in 15 seconds and wanted to save the current user timeout value and set it to 15 seconds when the user ran my application and restore the initial value when he closed my application. I did not find any library to do it so I wrote my first library to change system settings and it works great with SETTING_SCREEN_OFF_TIMEOUT = "screen_off_timeout". Then I tried to test my library and change the ACTION_AIRPLANE_MODE_CHANGED As String = "android.intent.action.AIRPLANE_MODE". I can toggle the airplane mode but need to intent the OS to let it know that air plane mode has changed. When I do the following code in my library it works fine; Code: Copy Intent intent = new Intent("android.intent.action.AIRPLANE_MODE"); intent.putExtra("state", 1); pBA.context.sendBroadcast(intent); but I did not find a way to do it with the intent function of A4B. Code: Copy Dim Intent1 As Intent Intent1.Initialize(Intent1.ACTION_CALL, "android.intent.action.AIRPLANE_MODE") Intent1.PutExtra("state",1) StartActivity(Intent1) or Code: Copy Dim Intent1 As Intent Intent1.Initialize("android.intent.action.AIRPLANE_MODE","") Intent1.PutExtra("state",1) StartActivity(Intent1) or any other alternative I tried I get the error android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.AIRPLANE_MODE flg=0x20000 (has extras) } Anyone has a clue what I'm doing wrong ? Note: Maybe there is another way to change the airplane mode but I just wanted to test my library and know how to make it work for all the other system settings that I may want to change... without recoding the intent functions to make it work... Thanks
thedesolatesoul Expert Licensed User Longtime User Jul 3, 2013 #2 You need to broadcast the intent using the Phone library. Basic4android - Phone Upvote 0
pfillion Member Licensed User Longtime User Jul 3, 2013 #3 thedesolatesoul said: You need to broadcast the intent using the Phone library. Basic4android - Phone Click to expand... Thanks a lot... I saw that it was a broadcast action but did not know that the phone library could do it. Thanks again Last edited: Jul 3, 2013 Upvote 0
thedesolatesoul said: You need to broadcast the intent using the Phone library. Basic4android - Phone Click to expand... Thanks a lot... I saw that it was a broadcast action but did not know that the phone library could do it. Thanks again