Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.phx.batterylogger"
- android:versionCode="1"
- android:versionName="1.0"
- android:installLocation="internalOnly">
- <uses-sdk android:minSdkVersion="8" />
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.BATTERY_STATS" />
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <service android:name=".BatteryLogger"/>
- <receiver android:name=".StartupIntentReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
- </application>
- </manifest>
- package com.phx.batterylogger;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- public class StartupIntentReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Intent serviceIntent = new Intent(context, BatteryLogger.class);
- context.startService(serviceIntent);
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="pack.saltriver" android:versionCode="1" android:versionName="1.0"
- android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <receiver android:name=".autostart">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
- <activity android:name=".hello"></activity>
- <service android:enabled="true" android:name=".service" />
- </application>
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
- </manifest>
- public class autostart extends BroadcastReceiver
- {
- public void onReceive(Context arg0, Intent arg1)
- {
- Intent intent = new Intent(arg0,service.class);
- arg0.startService(intent);
- Log.i("Autostart", "started");
- }
- }
- public class service extends Service
- {
- private static final String TAG = "MyService";
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
- public void onDestroy() {
- Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show();
- Log.d(TAG, "onDestroy");
- }
- @Override
- public void onStart(Intent intent, int startid)
- {
- Intent intents = new Intent(getBaseContext(),hello.class);
- intents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intents);
- Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
- Log.d(TAG, "onStart");
- }
- }
- public class hello extends Activity
- {
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Toast.makeText(getBaseContext(), "Hello........", Toast.LENGTH_LONG).show();
- }
- }
- public class MyReceiver extends BroadcastReceiver{
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d("TAG", "MyReceiver");
- Intent serviceIntent = new Intent(context, Test1Service.class);
- context.startService(serviceIntent);
- }
- }
- public class Test1Service extends Service {
- /** Called when the activity is first created. */
- @Override
- public void onCreate() {
- super.onCreate();
- Log.d("TAG", "Service created.");
- }
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- Log.d("TAG", "Service started.");
- return super.onStartCommand(intent, flags, startId);
- }
- @Override
- public void onStart(Intent intent, int startId) {
- super.onStart(intent, startId);
- Log.d("TAG", "Service started.");
- }
- @Override
- public IBinder onBind(Intent arg0) {
- return null;
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.test"
- android:versionCode="1"
- android:versionName="1.0"
- android:installLocation="internalOnly">
- <uses-sdk android:minSdkVersion="8" />
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.BATTERY_STATS"
- />
- <!-- <activity android:name=".MyActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER"></category>
- </intent-filter>
- </activity> -->
- <service android:name=".Test1Service"
- android:label="@string/app_name"
- >
- </service>
- <receiver android:name=".MyReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
- </application>
- </manifest>
- <receiver android:name=".StartupIntentReceiver">
- <receiver android:name="com.your.package.AutoStart">
- package com.test.juxo.testservice;
- import android.app.Service;
- import android.content.Intent;
- import android.os.Handler;
- import android.os.IBinder;
- import android.util.Log;
- public class MonService extends Service {
- @Override
- public void onDestroy() {
- Log.v("LTM", "onDestroy");
- super.onDestroy();
- }
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- Log.v( "LTM","onStartCommand" );
- int i = super.onStartCommand(intent, flags, startId);
- Thread monT = new Thread(new Sender());
- monT.start();
- return i;
- }
- @Override
- public IBinder onBind( Intent arg0 ) {
- Log.v( "LTM","onBind" );
- return null;
- }
- }
- package com.test.juxo.testservice;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.util.Log;
- public class MyReceiver extends BroadcastReceiver {
- @Override
- public void onReceive( Context ctx, Intent i ) {
- Log.v("LTM", "MyReceiver.onReceive : " + i.getAction());
- Intent intent = new Intent( ctx, MonService.class );
- ctx.startService(intent);
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.test.juxo.testservice"
- android:versionCode="1"
- android:versionName="1.1" >
- <uses-sdk android:minSdkVersion="8" />
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <service
- android:name="com.test.juxo.testservice.MonService"
- android:label="Mon beau service"
- android:enabled="true"
- android:exported="false" >
- </service>
- <receiver
- android:name="com.test.juxo.testservice.MyReceiver"
- android:enabled="true"
- android:exported="false" >
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
- </application>
- </manifest>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement