Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

registerBroadcastReceiver action_boot_completed not work

$
0
0

Hi, I'm trying to work with broadcast receiver in titanium alloy, but the Ti.Android.ACTION_BOOT_COMPLETED is not working.

testing with Ti.Android.ACTION_AIRPLANE_MODE_CHANGED, working normally.

I'm testing in android 2.3

it's my code in alloy.js

var broadCast = Ti.Android.createBroadcastReceiver({
        onReceived : function() {
 
            var intent = Ti.Android.createServiceIntent({
                url: 'service.js'
            });
 
            if(!Ti.Android.isServiceRunning(intent)) {
                intent.putExtra('interval', 1000);
                Ti.Android.startService(intent);
            }
        }
    });
 
    Ti.Android.registerBroadcastReceiver(broadCast, [Ti.Android.ACTION_BOOT_COMPLETED]);
in tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android" >   
        <uses-sdk android:minSdkVersion="10" targetSdkVersion="16"/>            
        <manifest>
            <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
            <application android:theme="@style/NoTitleBar" />               
        </manifest>
        <services>
            <service url="service.js" type="interval"/>
        </services>
</android>
and service.js

Ti.API.info('Server is running...');

some help, thanks..


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>