Skip to content

Commit a61c246

Browse files
author
geremy
committed
changing package name. Adding an activity to kickstart service on later versions of Android OS.
1 parent d2f87fc commit a61c246

5 files changed

Lines changed: 52 additions & 25 deletions

File tree

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.pubnub.examples.subscribeatboot"
3-
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
4-
android:versionCode="1"
5-
android:versionName="1.0" >
6-
>
2+
package="com.pubnub.examples.SubscribeAtBoot"
3+
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
4+
5+
android:versionCode="1"
6+
android:versionName="1.0">
7+
>
78
<uses-sdk
8-
android:minSdkVersion="8"
9-
android:targetSdkVersion="17" />
10-
9+
android:minSdkVersion="8"
10+
android:targetSdkVersion="16"/>
1111

1212
<application
13-
android:allowBackup="true"
14-
android:icon="@drawable/ic_launcher"
15-
android:label="@string/app_name"
16-
android:theme="@style/AppTheme" >
17-
<receiver android:name="com.pubnub.examples.subscribeatboot.BootReceiver" >
13+
android:allowBackup="true"
14+
android:icon="@drawable/icon"
15+
android:label="@string/app_name"
16+
>
17+
18+
<activity android:name=".HelloWorldActivity">
1819
<intent-filter>
19-
<action android:name="android.intent.action.BOOT_COMPLETED" />
20+
<action android:name="android.intent.action.MAIN"/>
21+
<category android:name="android.intent.category.LAUNCHER"/>
22+
</intent-filter>
23+
</activity>
24+
25+
26+
<receiver android:name=".BootReceiver">
27+
<intent-filter>
28+
<action android:name="android.intent.action.BOOT_COMPLETED"/>
2029
</intent-filter>
2130
</receiver>
2231

23-
<service
24-
android:name="com.pubnub.examples.subscribeatboot.PubnubService"
25-
android:enabled="true" />
32+
<service android:name=".PubnubService"/>
33+
2634
</application>
2735

28-
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" >
29-
</uses-permission>
36+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
3037
<uses-permission android:name="android.permission.INTERNET"/>
3138

3239
</manifest>

‎android/3.4/examples/SubscribeAtBoot/project.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-17
14+
target=android-16

android/3.4/examples/SubscribeAtBoot/src/com/pubnub/examples/subscribeatboot/BootReceiver.java renamed to android/3.4/examples/SubscribeAtBoot/src/com/pubnub/examples/SubscribeAtBoot/BootReceiver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.pubnub.examples.subscribeatboot;
1+
package com.pubnub.examples.SubscribeAtBoot;
22

33
import android.content.BroadcastReceiver;
44
import android.content.Context;
@@ -9,9 +9,10 @@ public class BootReceiver extends BroadcastReceiver {
99

1010
@Override
1111
public void onReceive(Context context, Intent arg1) {
12-
Intent intent = new Intent(context, PubnubService.class);
12+
Log.i("PubnubService", "PubNub BootReceiver Starting");
13+
Intent intent = new Intent(context, PubnubService.class);
1314
context.startService(intent);
14-
Log.i("PubnubService", "started");
15+
Log.i("PubnubService", "PubNub BootReceiver Started");
1516
}
1617

1718
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.pubnub.examples.SubscribeAtBoot;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
import android.util.Log;
7+
8+
9+
public class HelloWorldActivity extends Activity {
10+
public void onCreate(Bundle savedInstanceState) {
11+
super.onCreate(savedInstanceState);
12+
13+
Intent serviceIntent = new Intent(this, PubnubService.class);
14+
startService(serviceIntent);
15+
16+
Log.i("HelloWorldActivity", "PubNub Activity Started!");
17+
18+
}
19+
}

android/3.4/examples/SubscribeAtBoot/src/com/pubnub/examples/subscribeatboot/PubnubService.java renamed to android/3.4/examples/SubscribeAtBoot/src/com/pubnub/examples/SubscribeAtBoot/PubnubService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.pubnub.examples.subscribeatboot;
1+
package com.pubnub.examples.SubscribeAtBoot;
22

33
import org.json.JSONArray;
44
import org.json.JSONObject;
@@ -24,7 +24,7 @@ public class PubnubService extends Service {
2424

2525
private void showNotification(String s) {
2626
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
27-
Notification notification = new Notification(R.drawable.ic_launcher, s,
27+
Notification notification = new Notification(R.drawable.icon, s,
2828
System.currentTimeMillis());
2929
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
3030
new Intent(this, PubnubService.class), 0);

0 commit comments

Comments
 (0)