Unexpectedly Closed Application After Integration Parse.com - android

There was no problem while running my little android application. I integrated my application new feature. I am using real time push notification with using ready script by www.parse.com . There is no problem while running but when i closed screen and reopen .There is an error. Your application closed unexpectedly. I dont know why and there is no log.
I am using this code in my main activity before oncreate
Parse.initialize(this, "XXX", "YYY");
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
ParseAnalytics.trackAppOpened(getIntent());
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.islamiceducationquestions.v1"
android:versionCode="13"
android:versionName="8.0.1">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="com.islamiceducationquestions.v1.permission.C2D_MESSAGE" />
<uses-permission android:name="com.islamiceducationquestions.v1.permission.C2D_MESSAGE" />
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light.DarkActionBar">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="com.islamiceducationquestions.v1" />
</intent-filter>
</receiver>
</application>
</manifest>
Log is :
java.lang.RuntimeException: Unable to start receiver com.parse.ParseBroadcastReceiver: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2844)
at android.app.ActivityThread.access$1700(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(context, applicationId, clientKey) before using the Parse library.
at com.parse.Parse.checkContext(Parse.java:583)
at com.parse.Parse.getApplicationContext(Parse.java:191)
at com.parse.ManifestInfo.getContext(ManifestInfo.java:241)
at com.parse.ManifestInfo.getPackageManager(ManifestInfo.java:249)
at com.parse.ManifestInfo.getPackageInfo(ManifestInfo.java:272)
at com.parse.ManifestInfo.deviceSupportsGcm(ManifestInfo.java:357)
at com.parse.ManifestInfo.getPushType(ManifestInfo.java:129)
at com.parse.PushService.startServiceIfRequired(PushService.java:150)
at com.parse.ParseBroadcastReceiver.onReceive(ParseBroadcastReceiver.java:19)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2833)
... 10 more

As you can see here Android Parse.com Simple ListView Tutorial you will need to call Parse.initialize from Application's onCreate instead of from Activity or Service. do it as:
public class ParseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
// Add your initialization code here
Parse.initialize(this, YOUR_APPLICATION_ID, YOUR_CLIENT_KEY);
}
}
Also add ParseApplication in AndroidManifest.xml as application tag name:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:name="ParseApplication"
....

Related

Android AIDL - Unable to start service Intent

The error I am receiving is
2022-01-28 11:10:42.186 1651-3045/? W/ActivityManager: Unable to start service Intent { act=nveeaidle pkg=com.rchan.nveeapplication } U=0: not found
I have ensured the following code in both my applications (client and server). In my server manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rchan.nveeapplication">
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.NveeApplication">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.rchan.nvee_sdk.detectedactivity.DetectedActivityService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="nveeaidle" />
</intent-filter>
</service>
<receiver android:name="com.rchan.nvee_sdk.detectedactivity.DetectedActivityReceiver"/>
<!-- <receiver-->
<!-- android:name="com.rchan.nvee_sdk.detectedactivity.DetectedActivityReceiver"-->
<!-- android:exported="false"-->
<!-- android:process=":remote"-->
<!-- android:permission="com.google.android.gms.permission.ACTIVITY_RECOGNITION">-->
<!-- <intent-filter>-->
<!-- <action android:name="action.TRANSITIONS_DATA" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
</application>
</manifest>
In my client, I have this in my fragment:
private fun connectToRemoteService() {
val intent = Intent("nveeaidle")
val pack = "com.rchan.nveeapplication"
pack?.let {
intent.setPackage(pack)
activity?.applicationContext?.bindService(
intent, this, Context.BIND_AUTO_CREATE
)
}
}
I am not sure what is causing this warning, and I have tried out different solutions after searching on stackoverflow and google.
How do I test is:
Launch my server application
Launch my client application
I see the warning
Thank you for taking the time to read my question.
After recent changes, You can use <queries> <package android:name ="your package name" /> </queries>
https://developer.android.com/training/package-visibility/declaring
I did more searching and finally found the answer... All credits go to the SO answer here:
https://stackoverflow.com/a/55712326/3718584
TLDR:
Had to change the intent from implicit to explicit due to API 21
intent.setClassName("com.rchan.nveeapplication","com.rchan.nvee_sdk.detectedactivity.DetectedActivityService")

handshakeexception handshake error in client (os error wrong_version_number tls_record cc 242) Flutter app/Node server

I'm getting an handshakeexception handshake error in client (os error wrong_version_number tls_record cc 242) error whenever making an http request( I also tried https ) but from only one ( Cyclist app ) of the two Flutter apps that connect to Node.js server. I'm using the same IP address and port on both, the Android tablet on which I'm testing both apps and for my machine. I checked Manifest Android/src/main/AndroidManifest.xml to see if I was using android:usesCleartextTraffic="true"`on the working app ( Shop app ) but I'm not..
What else could I check to see what's causing the error in the Cyclist app??
This is the request:
Map<String, String> headers = {
'Content-Type': 'application/json',
'api_key': Environment.dbApiKey
};
// final Uri uri = Uri.https(Environment.dbUrl, '/api/routes');
final Uri uri = Uri.http(Environment.dbUrl, '/api/routes');
await post(uri, headers: headers, body: jsonEncode(route.toMap()))
.then((resp) {
print(
'RouteMongoRepository.saveRoute response status code is: ${resp
.statusCode}, \n response is : ${jsonDecode(resp.body)}');
UserRoute saved = UserRoute.fromMap(jsonDecode(resp.body)['data']);
print('saved route to Mongo is : ${saved.toMap().toString()}');
}) .catchError((e) => print('RouteMongoRepository.saveRoute error: $e')) ;
This is the Shop app manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vinny.fixit_shop_flutter">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="io.flutter.app.FlutterApplication"
android:allowBackup="false"
android:label="fixit shop"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
and this is the Cyclist app manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="io.flutter.app.FlutterApplication"
android:allowBackup="false"
android:label="fixit"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Found it..I was missing <uses-permission android:name="android.permission.INTERNET" />in Cyclist app AndroidManifest.xml

Parse.com push notifications don't get to devices on background

Today I've implemented Parse.com Push service in my app.
I've noticed that the push notifications are being sent only when the app is open. I've also noticed that whenever I'm turning on my device there is a message says "Unfortunately, tof has stopped". The Logcat says Unable to start receiver.
The full Logcat:
java.lang.RuntimeException: Unable to start receiver com.parse.ParseBroadcastReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context com.parse.ParsePlugins$Android.applicationContext()' on a null object reference
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2952)
at android.app.ActivityThread.access$1800(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1499)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context com.parse.ParsePlugins$Android.applicationContext()' on a null object reference
at com.parse.Parse.checkContext(Parse.java:440)
at com.parse.Parse.getApplicationContext(Parse.java:270)
at com.parse.ManifestInfo.getContext(ManifestInfo.java:324)
at com.parse.ManifestInfo.getPackageManager(ManifestInfo.java:328)
at com.parse.ManifestInfo.getPackageInfo(ManifestInfo.java:358)
at com.parse.ManifestInfo.deviceSupportsGcm(ManifestInfo.java:446)
at com.parse.ManifestInfo.getPushType(ManifestInfo.java:212)
at com.parse.PushService.startServiceIfRequired(PushService.java:222)
at com.parse.ParseBroadcastReceiver.onReceive(ParseBroadcastReceiver.java:19)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2945)
at android.app.ActivityThread.access$1800(ActivityThread.java:172)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1499)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5832)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
I've tried to search on the Web but I didn't find any solution. I guess that it's something about the receiver background operation.
I need an answer as quickly as possible, so if you know a bit about Parse SDK and it's push topic so please, help me 'cause I need to solve this today.
This is my code.
MainActivity.java:
ParsePush parsePush = new ParsePush();
ParseQuery pQuery = ParseInstallation.getQuery(); // <-- Installation query
pQuery.whereEqualTo("username", User_Name);
parsePush.sendMessageInBackground(message, pQuery);
AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="com.intap.tof.permission.C2D_MESSAGE" />
<uses-permission android:name="com.intap.tof.permission.C2D_MESSAGE" />
...
<service android:name="com.parse.PushService" />
<receiver android:name="com.intap.tof.Receiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="com.intap.tof" />
</intent-filter>
</receiver>
I also have this line on Receiver.java:
package com.intap.tof;
import android.content.Context;
import android.content.Intent;
import com.parse.ParsePushBroadcastReceiver;
public class Receiver extends ParsePushBroadcastReceiver {
#Override
public void onPushOpen(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
I need major help right now!! Please help me!
Follow the steps below. This code works fine and run the receiver on background. The original answer link: https://www.parse.com/apps/quickstart#parse_push/android/native/existing
MainActivity.java file
public void onCreate() {
Parse.initialize(this, "APPLICATION ID", "CLIENT KEY");
ParseInstallation.getCurrentInstallation().saveInBackground();
}
AndroidManifest.xml file
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: Change "com.parse.starter" to match your app's package name.
-->
<category android:name="com.parse.starter" />
</intent-filter>
</receiver>
Permissions.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
android:name="com.parse.starter.permission.C2D_MESSAGE" />
<uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />
Have a look at this.
public class MainApplication extends Application {
private static MainApplication instance = new MainApplication();
public MainApplication() {
instance = this;
}
public static Context getContext() {
return instance;
}
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, " ", " ");
PushService.setDefaultPushCallback(this, FabulaClient.class);
PushService.subscribe(this, "Barca", FabulaClient.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
taken from https://www.parse.com/questions/cannot-send-push-to-android-after-app-is-closed-until-screen-unlock
I've understood why I don't get the push notifications on background.
I've initialized parse sdk twice - on the OpenActivity.java and on ParseApplication.java. I've removed it from the OpenActivity.java and added this code line:
android:name=".ParseApplication"
To the application attribute on the AndroidManifest.xml and now I can get push notifications on background.

Notification is received but not displayed using Parse Unity SDK + Android

I'm using Parse Unity SDK for Android.
I've managed to register the device successfully.
void Start() {
//Parse Installation
if (ParseInstallation.CurrentInstallation != null && !string.IsNullOrEmpty(ParseInstallation.CurrentInstallation.DeviceToken))
{
Debug.Log("Device Token : " + ParseInstallation.CurrentInstallation.DeviceToken);
}
else
{
ParseInstallation installation = ParseInstallation.CurrentInstallation;
installation.Channels = new List<string> { Config.Instance.GetUserInfo().GetEmail() };
installation.SaveAsync().ContinueWith(t => {
if (t.IsFaulted || t.IsCanceled)
{
Debug.Log("Push subscription failed.");
}
else
{
Debug.Log("Push subscription success.");
}
});
//installation.
}
}
Only to discover that the notification is "received" but not being displayed neither in the app nor in the notifications bar.
I/GCM ( 1285): GCM message com.ahmed.app 0:1433935471473270%3f8fc5dbf9fd7ecd
I/ParsePushService( 7057): Push notification received. Payload: {"alert":"test","push_hash":"098f6bcd4621d373cade4e832627b4f6"}
I/ParsePushService( 7057): Push notification is handled while the app is foregrounded.
W/GCM-DMM ( 1285): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.ahmed.app (has extras) }
Also, Unity does not receive the notification (see code)
void Awake() {
ParsePush.ParsePushNotificationReceived += (sender, args) => {
#if UNITY_ANDROID
AndroidJavaClass parseUnityHelper = new AndroidJavaClass("com.parse.ParseUnityHelper");
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
//Debugging the payload
Debug.Log("Calling Parse from Unity and Payload is : " + args.StringPayload);
// Call default behavior.
parseUnityHelper.CallStatic("handleParsePushNotificationReceived", currentActivity, args.StringPayload);
#endif
};
}
This event doesn't get triggered.
Here's my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ahmed.app" android:theme="#android:style/Theme.NoTitleBar" android:versionName="1.0" android:versionCode="1" android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature" android:name="com.ahmed.app.permission.C2D_MESSAGE" />
<uses-permission android:name="com.ahmed.app.permission.C2D_MESSAGE" />
<application android:icon="#drawable/app_icon" android:label="#string/app_name" android:debuggable="false">
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="#string/app_name" android:screenOrientation="portrait" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>
<meta-data android:name="com.google.android.gms.version" android:value="4030500" />
<activity android:name="com.outlinegames.unibill.PurchaseActivity" android:label="#string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<service android:name="com.parse.ParsePushService" />
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.ahmed.app" />
</intent-filter>
</receiver>
</application>
Any idea what's the problem?
I have answered the same kind of question, I just wanted to let you know.
Parse Unity Push Sample not working
Basically, this line of your code is wrong:
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
You have to replace it by
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("com.unity3d.player.UnityPlayerNativeActivity");
Rather than downloading the SDK manually, I've downloaded the Parse Push sample project and copied the files to my project. Using the SDK 1.5.2 sample project, it works now.

Xtify + Worklight 6.1 integration in android environment

We have been working on the integration between worklight and xtify for push notifications. We are using version 2.3.2 for xtify sdk since latest version (2.4.2) made the app failed because a class not found exception.
The logic for using xtify has been added to the native code of the WL hybrid application as follows:
public class XtifyWL extends WLDroidGap {
public static final String XTIFY_APP_KEY = "xxxxxxxx-xxxxx-xxxx-xxxxx-xxxxxxxxx";
public static final String PROJECT_NUM = "xxxxxxxxxxxx"; // This is the Google Project Number
#Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
XtifySDK.start(getApplicationContext(), XTIFY_APP_KEY, PROJECT_NUM);
}
We are receiving the push notifications, but they are duplicated. We received one notification for worklight that fails when you try to open it, and one more for the native application thats works correctly.
How can we fix it?
About the issue with the SDK 2.4.2.2
The exception with SDK 2.4.2.2 is:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to get provider com.xtify.sdk.db.Provider: java.lang.ClassNotFoundException: com.xtify.sdk.db.Provider
at android.app.ActivityThread.installProvider(ActivityThread.java:4609)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4236)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4178)
at android.app.ActivityThread.access$1400(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.xtify.sdk.db.Provider
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.installProvider(ActivityThread.java:4594)
... 12 more
The only place where we see that class is in the AndroidManifest.xml
<provider android:name="com.xtify.sdk.db.Provider" android:authorities="com.XtifyApp.XTIFY_PROVIDER" android:exported="false" />
If we comment that line it fails with the next use of any class of the SDK. We have added the sdk .jar file to the libs folder of the android project and to the build path of the android project.
Thanks,
We have found why when we send a push notification, we see them duplicated (two notifications icons on the top).
It was an error in the AndroidManifest.xml, we added all the Xtify GCM configuration and we also left the worklight GCM configuration so we where registering two receivers.
But we have still the issue of "java.lang.ClassNotFoundException" when we try to use the latest Xtify SDK. Athough at least receiving simple notifications seems to work with the SDK 2.3.2.
This is the correct AndroidManifest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.XtifyApp" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18"/>
<supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="false"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Push permissions -->
<permission android:name="com.XtifyApp.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="com.XtifyApp.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="#string/app_name" android:debuggable="true" android:icon="#drawable/icon">
<activity android:name=".XtifyApp" android:label="#string/app_name" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.XtifyApp.XtifyApp.NOTIFICATION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.worklight.common.WLPreferences" android:label="Worklight Settings"></activity>
<!-- Start XTIFY -->
<provider android:name="com.xtify.sdk.db.Provider" android:authorities="com.XtifyApp.XTIFY_PROVIDER" android:exported="false" />
<receiver android:name=".XtifyNotifier" >
<intent-filter>
<action android:name="com.xtify.sdk.NOTIFIER" />
</intent-filter>
</receiver>
<receiver android:name="com.xtify.sdk.c2dm.C2DMBroadcastReceiver" >
<intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.XtifyApp" />
</intent-filter>
<intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.XtifyApp" />
</intent-filter>
</receiver>
<receiver android:name="com.xtify.sdk.NotifActionReceiver" />
<receiver android:name="com.xtify.sdk.wi.AlarmReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
<service android:name="com.xtify.sdk.location.LocationUpdateService" />
<service android:name="com.xtify.sdk.c2dm.C2DMIntentService" />
<service android:name="com.xtify.sdk.alarm.MetricsIntentService" />
<service android:name="com.xtify.sdk.alarm.TagIntentService" />
<service android:name="com.xtify.sdk.alarm.RegistrationIntentService" />
<service android:name="com.xtify.sdk.alarm.LocationIntentService" />
<!-- END XTIFY -->
<!-- Start Worklight GCM configuration -->
<!--
<service android:name=".GCMIntentService"/>
<service android:name=".ForegroundService"/>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.XtifyApp"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.XtifyApp"/>
</intent-filter>
</receiver>
-->
<!-- END Worklight GCM configuration -->
</application>
</manifest>

Categories

Resources