I am not able to receive push notifications at all. onPushReceieved method in my receiver class is never called.
Here's what my manifest looks like:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature"
android:name="com.compName.appName.permission.C2D_MESSAGE" />
<uses-permission android:name="com.compName.appName.permission.C2D_MESSAGE" />
<application>
.
.
<service android:name="com.parse.PushService" />
<receiver android:name="com.compName.appName.helpers.MyParsePushReciever"
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" />
<category android:name="com.compName.appName" />
</intent-filter>
</receiver>
</application
This is the init methods for Parse in my Applications onCreate Method:
Parse.initialize(this, app_id, client_id);
PushService.startServiceIfRequired(this);
ParseInstallation.getCurrentInstallation().saveInBackground();
Here is my Receiver class's onPushReceived method:
#Override
protected void onPushReceive(Context context, Intent intent) {
Log.i("hereeeeeeeeee === ", "on push recieve");
}
I am never able to see that Log. OnPushReceive never gets called. Is there something I am missing?
Check your manifest and gradle file, I think the package names are wrong.
I heard about parse.com is going to be off forever
and yes its down officially.
http://parse.com/
EDIT
As parse announced their shutdown recently, GCM is the only best option though it won’t comes with an admin interface.
You can follow this awesome tutorial for this.
http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-1/
I figured it out.
I had changed my package a long time ago. I had made changes to my manifest, but not in my gradle file.
Shout out to Taylor Courtney for continuing in helping me figure it out. He's the real MVP.
Related
i created an app that always start a service once the device has completed booting.
This is the Manifest code..
<receiver>
android:name="StartMyServiceAtBootReceiver"
android:directBootAware ="true"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<action android:name="android.intent.action.REBOOT"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
The service always start in some devices once boot is completed but in my own device which is running android 7.0, the boot completed service doesn't start unless i convert the app to system app using root access. Can someone tell me how to make the app to start the service on boot completed without converting it to a system app?
First of All
receiver android:name="StartMyServiceAtBootReceiver"
Your path to Receiver should written over here for example:
<receiver android:name=".receiver.BootReceiver">
first dot suggest your path till root of the package.
Create a BroadcastReceiver and register it to receive ACTION_BOOT_COMPLETED. You also need RECEIVE_BOOT_COMPLETED permission.
Read: Listening For and Broadcasting Global Messages , and Setting Alarms
Try into manifest
<receiver
android:name=".AutoStart"
android:enabled="true"
android:exported="true" >
<intent-filter android:priority="500" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
Make sure also to include the completed boot permission.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Also read this answer carefully
I am trying to stop the app I am working on from asking for USB permissions each time the USB device is disconnected. I have followed: USB device access pop-up suppression? without much luck.
The app does remember the USB device until the device is unplugged.
If it matters I am trying to connect the app to an Arduino Teensy.
This is what my manifest activity looks like
<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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter> <!-- For receiving data from another application -->
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="#xml/usb_device_filter" />
</activity>
</application>
And here is my usb_device_filter file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-device vendor-id="--hidden--" product-id="--hidden--" />
</resources>
Any help is welcome.
EDIT: I also look over at the Android Developer page and they say when using an intent filter for USB connections: If users accept, your application automatically has permission to access the device until the device is disconnected.
I would also like to point out that the suggested duplicate does not have the same issue as I am trying to solve. Their problem is having two activities while my problem deals with just one.
https://developer.android.com/guide/topics/connectivity/usb/host
We ended up opening the app automatically when the USB is inserted into the phone, because our project deals with the app being open all day.
The app only asks for permission to use the USB once for the phone and remembers it now, as long as the user connects the USB before opening the app and the phone is unlocked. The phone even remembers the permission after the phone is restarted.
This is kind of a work around, but it works for our needs. Hopefully this will help some others with the same problem.
As the asker here says, For your perpose (if I understood correctly) the following should be enough. That's right that he had a different problem but he started hes question saying that for your case it's working.
<activity android:name=".FirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="#xml/usb_device_filter" />
</activity>
I configured Parse API in my app and everything works except push notifications. I tried to send them from the site but they don't arrive in app.
I did everything as written in documentation, but I'm not able to receive notification pushes.
I was able to receive one and when I pressed it app crashed. Now I tried to change something but even with reversing I cannot receive them anymore. How can I resolve my problem?
EDIT: Since some users may be interested, here's the parts of the code I used for push notifications:
Main Class (not MainActivity though):
public class InstantsApplication extends Application {
public void onCreate() {
super.onCreate();
// Hidden
Parse.initialize(this, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("", new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
} else {
Log.e("com.parse.push", "failed to subscribe for push", e);
}
}
}
}
AndroidManifest (permissions not here included, trust me I have put them):
<!-- PARSE -->
<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.tutorials.pushnotifications" to match your app's package name.
-->
<!-- I have hidden package name root for this question -->
<category android:name="com.xxxxxxxx.instants" />
</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>
</application>
I met this problem before, that because you use the newest Parse api.
There are just a few changes you need to make.
First, to fix the error directly caused by issuing the push from the Parse backend you need to declare a notification icon for the Parse push in your Manifest.
<meta-data android:name="com.parse.push.notification_icon"
android:resource="#drawable/ic_launcher"/>
use before the closing application-Tag.
Issuing another push from the backend now will give you a push notification as you expect. So far so good. Clicking the push will result in an app crash again. To fix this you need to remove the now deprecated call PushService.setDefaultPushCallback(...) and add your own Receiver class. I did this in the *.util package just as the following:
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);
}
}
Next, change the default Parse receiver to the one just created: - Go to your Manifest file.
<receiver
android:name="your.package.name.utils.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>
is it possible to keep track of install/uninstall actions of Applications on the Android system? I was not able to find a proper Intent Action or Broadcast event so far.
What I'm searching for an observer for applications like there are observers for Calendar or CallLog changes. Does there exists an CONTENT_URI or Broadcast event?
Regards
You can create a broadcast receiver for package install and unistall.
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
For More info go to link
How can I read NFC tag in background via service? I already can read it in activity(I've found some source codes but I don't really understand how it works) but I can't find anything about reading it in Service or Runnable.
Thanks for help
Finally i figured out how to solve it. I have to use these intent filters in AndroidManifest.xml to properly run my activity.
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>