3

Titanium アプリケーションでバックグラウンド サービスを使用したいと考えています。

Titanium Android アプリケーションに挿入する必要があるすべてのコードを使用しました。

TiApp.xml ファイル内: サービスをここに登録します。

<services>
    <service url='BGServ.js' type="interval"/>
</services>

ここで、「BGServ.js」ファイルはapp/libフォルダーに配置されます。


BGServ.js ファイル内: 当社のサービス ファイル コード

var service = Titanium.Android.currentService;
var intent = service.intent;
Ti.API.info('Background Service Started');
Ti.API.info('Background Service of Platform : ' + Titanium.Platform.osname + ' Started');

service.addEventListener('resume', function(e) {
	Titanium.API.info('Service code resumes, iteration ' + e.iteration);
});

service.addEventListener('pause', function(e) {
	Titanium.API.info('Service code pauses, iteration ' + e.iteration);
}); 


index.js ファイル内: ここで Service Intent を作成します

var intent = Titanium.Android.createServiceIntent({
	url : '/BGServ.js'
});
intent.putExtra('interval', 1000);
intent.putExtra('message_to_echo', 'Test Service');
Titanium.Android.startService(intent);


問題: プロジェクトで Android サービスが機能していません。Ti.API.info() を持つ BGServ.js では、コンソールにも出力されません。私はここで構造体です。助けてください。

TiSDK バージョン: 3.5.0 GA

ありがとう、

アビドゥサイン

4

1 に答える 1