BroadcastReceiver not working in the background OREO+ - java

In my application there are two receivers, one receives calls (MyReceiverCall) and the second SMS (MyReceiverSms).
When you start the app everything works fine, I get a notification when I receive an SMS or call.
But if I close the app in task Manager then nothing wants to work and all incoming SMS and calls are ignored by the receiver.
I had assumptions that can be simply service with my notification does not start, but through logs I understood that the receiver simply does not work. (But so far the assumption is that services are to blame)
My code
MyReceiverCall.class
public class MyReceiverCall extends BroadcastReceiver {
private static final String ACTION = "android.intent.action.PHONE_STATE";
#Override
public void onReceive(Context context, Intent intent) {
Log.i("123","sakuraso13 ReceiverCall");
if (intent != null && intent.getAction() != null) {
if (intent.getAction().equals(ACTION)) {
String number=intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING) & number!=null) {
// some operation with number phone
Intent intentService = new Intent(context, ServiceMain.class);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
context.startForegroundService(intentService);
}else {
context.startService(intentService);
}
}
}
}
}
}
MyReceiverSms.class
public class MyReceiverSms extends BroadcastReceiver {
private static final String TAG="MyReceiverSms";
private static final String ACTION="android.provider.Telephony.SMS_RECEIVED";
#Override
public void onReceive(Context context, Intent intent) {
Log.i("123","sakuraso13 ReceiverWorking");
if(intent != null && intent.getAction()!=null) {
if (intent.getAction().equals(ACTION)) {
// some operation with number phone
Intent intentService=new Intent(context, ServiceMain.class);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
context.startForegroundService(intentService);
}else {
context.startService(intentService);
}
}
}
}
}
}
ServiceMain.class
public class ServiceMain extends Service {
public ServiceMain() {
}
#Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
return null;
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundNotification();
}
showSimpleNotification();
}
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.service.detector">
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.BROADCAST_SMS"/>
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:name="detector.sakuraso13.App"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:networkSecurityConfig="#xml/network_security_config"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<service
android:name="detector.sakuraso13.Service.ServiceMain"
android:enabled="true"
android:exported="true"></service>
<receiver
android:name="detector.sakuraso13.Broadcaster.MyReceiverCall"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="2147483647">
<action android:name="android.intent.action.NEW_OUTGOING_CALL"
android:priority="2147483647"/>
<action android:name="android.intent.action.PHONE_STATE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver
android:name="detector.sakuraso13.Broadcaster.MyReceiverSms"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<activity android:name="detector.sakuraso13.Main.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Sometimes in logs I can see similar when calling when the application is closed:
2019-11-19 21:57:10.978 1271-1289/? W/BroadcastQueue: Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x1000010 (has extras) } to app.service.detector/detector.sakuraso13.Broadcaster.MyReceiverCall requires android.permission.READ_PRIVILEGED_PHONE_STATE due to sender android (uid 1000)
2019-11-19 21:57:13.030 1271-6637/? W/BroadcastQueue: Permission Denial: receiving Intent { act=android.intent.action.PHONE_STATE flg=0x1000010 (has extras) } to app.service.detector/detector.sakuraso13.Broadcaster.MyReceiverCall requires android.permission.READ_PRIVILEGED_PHONE_STATE due to sender android (uid 1000)

Related

Android - can't get broadcastreceiver to work

I try to launch a service at boot, but it never starts the service. I added <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/> to the intent-filter of the receiver, but when I connect my android 8.0 phone to power, it also doesn't work.
manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.madmagic.oqrpc">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:usesCleartextTraffic="true"
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" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".MainService" />
<receiver
android:name=".StartAtBoot">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
</intent-filter>
</receiver>
</application>
</manifest>
StartAtBoot:
public class StartAtBoot extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "received", Toast.LENGTH_LONG).show(); //this never shows up when connecting to power
Intent i = new Intent(context, MainService.class);
context.startService(i);
}
}
MainService:
public class MainService extends Service {
public static boolean isRunning = false;
#Override
public IBinder onBind(Intent intent) {
return null;
}
#Override
public void onCreate() {
isRunning = true;
Toast.makeText(this, "Service started", Toast.LENGTH_LONG).show();
ConnectionChecker.run(this); //when device has wifi connection, this will run connected() method
}
#Override
public void onDestroy() {
isRunning = false;
}
public void connected() {
//things to do when it has wifi connection
}
}
In my MainActivity class, I start this service using the same way as in my StartAtBoot class, and there it works fine when I open the application. So the service is working fine, its just that the StartAtBoot class doesn't run the code.
ACTION_POWER_CONNECTED is not a listed exception to the limits on implicit Intent broadcasts. Your app cannot register for it in the manifest.
If your goal is to do work periodically, but only if the device has power, use JobScheduler or WorkManager.

No voice is recording while a file is saved

I am trying to make call recorder in it everything is working fine I am getting file of the audio too but when I try to listen to it I can't able to here the voices here my code friends please help me out I cant able to understand the error.
Broadcastreceiver.java
public class PhoneStateReceiver extends BroadcastReceiver {
MediaRecorder startrecording;
boolean recordstarted = false;
#Override
public void onReceive(Context context, Intent intent) {
startrecording = new MediaRecorder();
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
Toast.makeText(context, "Incoming call", Toast.LENGTH_SHORT).show();
}
if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
Toast.makeText(context, "Received", Toast.LENGTH_SHORT).show();
startrecording.reset();
startrecording.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
startrecording.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
startrecording.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
startrecording.setOutputFile("/sdcard/sample.3gp");
startrecording.setOnErrorListener(new MediaRecorder.OnErrorListener() {
#Override
public void onError(MediaRecorder mediaRecorder, int i, int i1) {
Log.d("Error",mediaRecorder.toString()+" "+String.valueOf(i)+" "+String.valueOf(i1));
}
});
startrecording.setOnInfoListener(new MediaRecorder.OnInfoListener() {
#Override
public void onInfo(MediaRecorder mediaRecorder, int i, int i1) {
Log.d("info",mediaRecorder.toString()+" "+String.valueOf(i)+" "+String.valueOf(i1));
}
});
try {
startrecording.prepare();
startrecording.start();
recordstarted = true;
Toast.makeText(context, "Recording Started", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}
if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
Toast.makeText(context, "Idle", Toast.LENGTH_SHORT).show();
if (recordstarted) {
startrecording = new MediaRecorder();
startrecording.stop();
startrecording.reset();
startrecording.release();
recordstarted = false;
}
}
}
}
Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prominere.prominere.incomingcall">
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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>
</activity>
<receiver android:name=".PhoneStateReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>

What forces android activity to be destroyed when launching another activity

I'm trying to add in-app purchases and when I call OpenIabHelper::launchPurchaseFlow function:
I see Google Play purchase window
onStop and onDestroy are executed in my main activity without calls to onActivityResult
So in the end I left with GooglePlay window and my dead app
I tried to start another activity via startActivityForResult and it worked fine
(nothing was destroyed and onActivityResult was called), so it seems that problem is with OpenIAB library
Therefore there's my question:
What can possibly force my activity to be destroyed after calling OpenIabHelper::launchPurchaseFlow ?
It doesn't seem to be system because it has enough memory and as I said startActivityForResult works fine.
Also there's no exceptions being trown so I'm puzzled
Any help would be appreciated
MyActivity.java
public class MyActivity extends AppCompatActivity {
private OpenIabHelper m_helper;
private Boolean m_bOpenIabInitialized = false;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OpenIabHelper.Options.Builder builder = new OpenIabHelper.Options.Builder()
.addAvailableStores(new GooglePlay(this,null))
.addPreferredStoreName(OpenIabHelper.NAME_GOOGLE)
.setStoreSearchStrategy(OpenIabHelper.Options.SEARCH_STRATEGY_INSTALLER_THEN_BEST_FIT)
.setVerifyMode(OpenIabHelper.Options.VERIFY_SKIP)
.setCheckInventory(false);
m_helper = new OpenIabHelper(this, builder.build());
m_helper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
m_bOpenIabInitialized = result.isSuccess();
}
});
}
public void onListViewItemClicked(String sku, String payload) {
if (m_bOpenIabInitialized == null || !m_bOpenIabInitialized) return;
m_helper.launchPurchaseFlow(this, sku, 10001, null, payload);
}
#Override
public void startActivityForResult(Intent intent, int RequestCode) {
// never reaches here
Log.d(TAG, "startActivityForResult()");
}
#Override
protected void onActivityResult(int RequestCode, int ResultCode, Intent data) {
// never reaches here
Log.d(TAG, "onActivityResult()");
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<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" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:allowBackup="true"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MyActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Have you tried changing the activity's launchMode? Maybe the singleTop launch mode will preserve your activity:
<activity
android:name=".MyActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
android:configChanges="orientation|screenSize|keyboardHidden|screenLayout"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You can find more about launch modes here:
https://developer.android.com/guide/topics/manifest/activity-element.html#lmode

Can't send push to android using GCM

Sorry for my english. I have spent 2 days but I can't send push messages to android. I use google cloud message. For example in gcm I create a new project and I have an id:
Then I enabled gcm and added the server key
I have code like this:
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alexy.gcmclient">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.hmkcode.android.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.hmkcode.android.gcm.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<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>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.hmkcode.android.gcm" />
</intent-filter>
</receiver>
<service
android:name=".GcmMessageHandler"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
</application>
</manifest>
GcmBroadcastReceiver
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Log.e("GcmBroadcastReceiver", "GcmBroadcastReceiver");
// Explicitly specify that GcmMessageHandler will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GcmMessageHandler.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
GcmMessageHandler
public class GcmMessageHandler extends IntentService {
String mes;
private Handler handler;
public GcmMessageHandler() {
super("GcmMessageHandler");
}
#Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
handler = new Handler();
Log.e("GcmMessageHandler", "GcmMessageHandler");
}
#Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
// The getMessageType() intent parameter must be the intent you received
// in your BroadcastReceiver.
String messageType = gcm.getMessageType(intent);
Log.e("message", messageType);
}
Main
public class MainActivity extends Activity implements OnClickListener{
Button btnRegId, unregister;
EditText etRegId;
GoogleCloudMessaging gcm;
String regid;
String PROJECT_NUMBER = "308****";
private BroadcastReceiver mRegistrationBroadcastReceiver;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
unregister = (Button) findViewById(R.id.unregister);
btnRegId = (Button) findViewById(R.id.btnGetRegId);
etRegId = (EditText) findViewById(R.id.etRegId);
btnRegId.setOnClickListener(this);
}
public void getRegId(){
new AsyncTask<Void, Void, String>() {
#Override
protected String doInBackground(Void... params) {
String msg = "";
try {
InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
String token = instanceID.getToken(PROJECT_NUMBER,
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
msg = token;
//apiKey = msg;
GcmPubSub.getInstance(getApplicationContext()).subscribe(token, "/topics/users", null);
} catch (IOException ex) {
msg = "Error :" + ex.getMessage();
}
return msg;
}
#Override
protected void onPostExecute(String msg) {
etRegId.setText(msg + "\n");
Log.e("key", msg);
}
}.execute(null, null, null);
}
#Override
public void onClick(View v) {
getRegId();
}
}
I use service and tried to send some push messages to the device. In service it says Success. But the push in android is not coming (I have no output in the log)
I assume your app package name must be com.example.alexy.gcmclient or replace the package name build.gradle
defaultConfig
applicationId "com.yourpackge"
<permission
android:name="com.example.alexy.gcmclient.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.example.alexy.gcmclient.permission.C2D_MESSAGE" />
<receiver android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.alexy.gcmclient" />
</intent-filter>
</receiver>
The package names for C2D_MESSAGE are wrong, change them to your package name. Also, make sure you have the configuration file near the build.gradle of your app directory. Edit: go through all of the manifest and change wherever you see hmk to your package name. Your package name should be com.example.alexy.gcmclient as per your manifest.

Push notify doesn't arrive

I build an android app composed by a web view, in parse.com i've got my device registered but when i send a push notification in "pushes sent" there is 0 pushes.
this is my Mainactivity:
import com.party.bparty.MainActivity;
import com.parse.Parse;
import com.parse.ParseInstallation;
import com.parse.ParsePush;
import com.parse.ParseQuery;
import com.parse.PushService;
public class MainActivity extends ActionBarActivity {
private WebView mWebView;
private String url = "http://www.bestparty.altervista.org";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//attivo parse per le notifiche
Parse.initialize(this,"zJxpd9798Ns6A9rzUDpe78ElRY0I99ES3LD6nDQV","kmAmA1iTbC32BTE9ERtzNOoHXbJchhIn6tyPXKMi");
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
//...
//...initializing and loading the contentview and the webview
}
//options menu omitted
}
this is my MycustomReceiver
public class MyCustomReceiver extends BroadcastReceiver {
private static final String TAG = "MyCustomReceiver";
#Override
public void onReceive(Context context, Intent intent) {
try {
if (intent == null)
Log.d(TAG, "Receiver intent null");
else {
String action = intent.getAction();
Log.d(TAG, "got action " + action );
if (action.equals("com.party.bparty.UPDATE_STATUS")) {
String channel = intent.getExtras().getString("com.parse.Channel");
JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data"));
Log.d(TAG, "got action " + action + " on channel " + channel + " with:");
Iterator itr = json.keys();
while (itr.hasNext()) {
String key = (String) itr.next();
if (key.equals("customdata")) {
Intent pupInt = new Intent(context, ShowPopUp.class);
pupInt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
context.getApplicationContext().startActivity(pupInt);
}
Log.d(TAG, "..." + key + " => " + json.getString(key));
}
}
}
}
catch (JSONException e) {
Log.d(TAG, "JSONException: " + e.getMessage());
}
}
}
and this is my ShowPopup
public class ShowPopUp extends Activity implements OnClickListener {
Button ok, cancel;
boolean click = true;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Cupon");
setContentView(R.layout.popupdialog);
ok = (Button)findViewById(R.id.popOkB);
ok.setOnClickListener(this);
cancel = (Button)findViewById(R.id.popCancelB);
cancel.setOnClickListener(this);
}
#Override
public void onClick(View arg0) {
finish();
}
}
And this is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.party.bparty"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.androidhive.pushnotifications.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.androidhive.pushnotifications.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
<activity
android:name="com.party.bparty.ShowPopUp"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
</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.RECEIVE_BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.party.bparty.MyCustomReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="com.iakremera.pushnotificationdemo.UPDATE_STATUS" />
</intent-filter>
</receiver>
</application>
</manifest>
Where's my error?
I do it, but it doesn't work anyway
" if (action.equals("com.party.bparty.UPDATE_STATUS")) {
Pick one, either com.party.bparty.UPDATE_STATUS or com.iakremera.pushnotificationdemo.UPDATE_STATUS"
but Now i have 1 "PUSH SENT" in push sent, but my device doesn't show any push
Your receiver has the wrong filter. Your receiver is declared as this:
<receiver android:name="com.party.bparty.MyCustomReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="com.iakremera.pushnotificationdemo.UPDATE_STATUS" />
</intent-filter>
</receiver>
but you are checking for a different intent action in the code:
if (action.equals("com.party.bparty.UPDATE_STATUS")) {
Pick one, either com.party.bparty.UPDATE_STATUS or com.iakremera.pushnotificationdemo.UPDATE_STATUS and also make sure that Parse knows which one it is when you perform the push itself.

Categories