LocationManager.addProximityAlert(…) throws IllegalArgumentException(“pending intent must be targeted to package”) Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!android pending intent notification problemMultiple Instances of Pending IntentPending intent in notification not workingHow to fix Service Instance Issue?Prevent service collisions after aapt --rename-manifest-packagePicasso IllegalArgumentException Target must not be nullService Intent must be explicit: Intenthow to handle orphaned pending intent by runtime exceptionandroid- Intentional '%' in string throws IllegalArgumentExceptionNew alarm with different data overrides already set alarm

Disembodied hand growing fangs

What do you call the main part of a joke?

Crossing US/Canada Border for less than 24 hours

How to play a character with a disability or mental disorder without being offensive?

How much damage would a cupful of neutron star matter do to the Earth?

How fail-safe is nr as stop bytes?

What's the meaning of "fortified infraction restraint"?

How to install press fit bottom bracket into new frame

What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?

How to tell that you are a giant?

Putting class ranking in CV, but against dept guidelines

Time to Settle Down!

Did Deadpool rescue all of the X-Force?

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

Do any jurisdictions seriously consider reclassifying social media websites as publishers?

Using audio cues to encourage good posture

How often does castling occur in grandmaster games?

ArcGIS Pro Python arcpy.CreatePersonalGDB_management

Drawing without replacement: why is the order of draw irrelevant?

Take 2! Is this homebrew Lady of Pain warlock patron balanced?

If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?

Hangman Game with C++

Why weren't discrete x86 CPUs ever used in game hardware?

Selecting user stories during sprint planning



LocationManager.addProximityAlert(…) throws IllegalArgumentException(“pending intent must be targeted to package”)



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!android pending intent notification problemMultiple Instances of Pending IntentPending intent in notification not workingHow to fix Service Instance Issue?Prevent service collisions after aapt --rename-manifest-packagePicasso IllegalArgumentException Target must not be nullService Intent must be explicit: Intenthow to handle orphaned pending intent by runtime exceptionandroid- Intentional '%' in string throws IllegalArgumentExceptionNew alarm with different data overrides already set alarm



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to set up a geofence using LocationManager.addProximityAlert(...), but I get an IllegalArgumentException("pending intent must be targeted to package").



Here is my code:



Intent intent = new Intent(context, MyIntentService.class);
intent.setPackage(context.getPackageName());
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

locationManager.addProximityAlert(latitude, longitude, radius, expiration, pendingIntent);


The first thing that LocationManager does is call checkPendingIntent(intent) which calls intent.isTargetedToPackage() which calls ActivityManagerNative.isIntentSenderTargetedToPackage(IIntentSender sender) https://android.googlesource.com/platform/frameworks/base/+/c80f952/core/java/android/app/ActivityManagerNative.java#4609



The result is false and I get an IllegalArgumentException("pending intent must be targeted to package").



The same thing works fine if I use a BroadcastReceiver instead of an IntentService.



How do I fix this IllegalArgumentException?



P.S. I use LocationManager for devices which don't have Play Services installed. Using IntentService to immediately run some API requests, which may take some time. IntentService is registered in manifest as <service android:name=".MyIntentService" android:exported="false"/>.



Update: here's the code that works with BroadcastReceiver. AndroidManifest:



<receiver android:name=".MyBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="MyBroadcastReceiver.GEOFENCE_TRANSITION"/>
</intent-filter>
</receiver>


java code:



Intent intent = new Intent("MyBroadcastReceiver.GEOFENCE_TRANSITION");
intent.setPackage(context.getPackageName());
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);









share|improve this question
























  • Can you post your manifest entry for the BroadcastReceiver that works

    – Ge3ng
    Mar 8 at 21:10












  • @Ge3ng see update in the post.

    – aleksey_chugaev
    Mar 9 at 2:19











  • are both of these intents used? You may have a conflict of ids

    – Ge3ng
    Mar 9 at 19:32











  • No, only one of them is used at the same time.

    – aleksey_chugaev
    Mar 10 at 6:26











  • Try changing the 0 in you PendingIntents to unique values.

    – Ge3ng
    Mar 10 at 6:27

















0















I am trying to set up a geofence using LocationManager.addProximityAlert(...), but I get an IllegalArgumentException("pending intent must be targeted to package").



Here is my code:



Intent intent = new Intent(context, MyIntentService.class);
intent.setPackage(context.getPackageName());
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

locationManager.addProximityAlert(latitude, longitude, radius, expiration, pendingIntent);


The first thing that LocationManager does is call checkPendingIntent(intent) which calls intent.isTargetedToPackage() which calls ActivityManagerNative.isIntentSenderTargetedToPackage(IIntentSender sender) https://android.googlesource.com/platform/frameworks/base/+/c80f952/core/java/android/app/ActivityManagerNative.java#4609



The result is false and I get an IllegalArgumentException("pending intent must be targeted to package").



The same thing works fine if I use a BroadcastReceiver instead of an IntentService.



How do I fix this IllegalArgumentException?



P.S. I use LocationManager for devices which don't have Play Services installed. Using IntentService to immediately run some API requests, which may take some time. IntentService is registered in manifest as <service android:name=".MyIntentService" android:exported="false"/>.



Update: here's the code that works with BroadcastReceiver. AndroidManifest:



<receiver android:name=".MyBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="MyBroadcastReceiver.GEOFENCE_TRANSITION"/>
</intent-filter>
</receiver>


java code:



Intent intent = new Intent("MyBroadcastReceiver.GEOFENCE_TRANSITION");
intent.setPackage(context.getPackageName());
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);









share|improve this question
























  • Can you post your manifest entry for the BroadcastReceiver that works

    – Ge3ng
    Mar 8 at 21:10












  • @Ge3ng see update in the post.

    – aleksey_chugaev
    Mar 9 at 2:19











  • are both of these intents used? You may have a conflict of ids

    – Ge3ng
    Mar 9 at 19:32











  • No, only one of them is used at the same time.

    – aleksey_chugaev
    Mar 10 at 6:26











  • Try changing the 0 in you PendingIntents to unique values.

    – Ge3ng
    Mar 10 at 6:27













0












0








0








I am trying to set up a geofence using LocationManager.addProximityAlert(...), but I get an IllegalArgumentException("pending intent must be targeted to package").



Here is my code:



Intent intent = new Intent(context, MyIntentService.class);
intent.setPackage(context.getPackageName());
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

locationManager.addProximityAlert(latitude, longitude, radius, expiration, pendingIntent);


The first thing that LocationManager does is call checkPendingIntent(intent) which calls intent.isTargetedToPackage() which calls ActivityManagerNative.isIntentSenderTargetedToPackage(IIntentSender sender) https://android.googlesource.com/platform/frameworks/base/+/c80f952/core/java/android/app/ActivityManagerNative.java#4609



The result is false and I get an IllegalArgumentException("pending intent must be targeted to package").



The same thing works fine if I use a BroadcastReceiver instead of an IntentService.



How do I fix this IllegalArgumentException?



P.S. I use LocationManager for devices which don't have Play Services installed. Using IntentService to immediately run some API requests, which may take some time. IntentService is registered in manifest as <service android:name=".MyIntentService" android:exported="false"/>.



Update: here's the code that works with BroadcastReceiver. AndroidManifest:



<receiver android:name=".MyBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="MyBroadcastReceiver.GEOFENCE_TRANSITION"/>
</intent-filter>
</receiver>


java code:



Intent intent = new Intent("MyBroadcastReceiver.GEOFENCE_TRANSITION");
intent.setPackage(context.getPackageName());
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);









share|improve this question
















I am trying to set up a geofence using LocationManager.addProximityAlert(...), but I get an IllegalArgumentException("pending intent must be targeted to package").



Here is my code:



Intent intent = new Intent(context, MyIntentService.class);
intent.setPackage(context.getPackageName());
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

locationManager.addProximityAlert(latitude, longitude, radius, expiration, pendingIntent);


The first thing that LocationManager does is call checkPendingIntent(intent) which calls intent.isTargetedToPackage() which calls ActivityManagerNative.isIntentSenderTargetedToPackage(IIntentSender sender) https://android.googlesource.com/platform/frameworks/base/+/c80f952/core/java/android/app/ActivityManagerNative.java#4609



The result is false and I get an IllegalArgumentException("pending intent must be targeted to package").



The same thing works fine if I use a BroadcastReceiver instead of an IntentService.



How do I fix this IllegalArgumentException?



P.S. I use LocationManager for devices which don't have Play Services installed. Using IntentService to immediately run some API requests, which may take some time. IntentService is registered in manifest as <service android:name=".MyIntentService" android:exported="false"/>.



Update: here's the code that works with BroadcastReceiver. AndroidManifest:



<receiver android:name=".MyBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="MyBroadcastReceiver.GEOFENCE_TRANSITION"/>
</intent-filter>
</receiver>


java code:



Intent intent = new Intent("MyBroadcastReceiver.GEOFENCE_TRANSITION");
intent.setPackage(context.getPackageName());
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);






android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 2:18







aleksey_chugaev

















asked Mar 8 at 20:44









aleksey_chugaevaleksey_chugaev

7114




7114












  • Can you post your manifest entry for the BroadcastReceiver that works

    – Ge3ng
    Mar 8 at 21:10












  • @Ge3ng see update in the post.

    – aleksey_chugaev
    Mar 9 at 2:19











  • are both of these intents used? You may have a conflict of ids

    – Ge3ng
    Mar 9 at 19:32











  • No, only one of them is used at the same time.

    – aleksey_chugaev
    Mar 10 at 6:26











  • Try changing the 0 in you PendingIntents to unique values.

    – Ge3ng
    Mar 10 at 6:27

















  • Can you post your manifest entry for the BroadcastReceiver that works

    – Ge3ng
    Mar 8 at 21:10












  • @Ge3ng see update in the post.

    – aleksey_chugaev
    Mar 9 at 2:19











  • are both of these intents used? You may have a conflict of ids

    – Ge3ng
    Mar 9 at 19:32











  • No, only one of them is used at the same time.

    – aleksey_chugaev
    Mar 10 at 6:26











  • Try changing the 0 in you PendingIntents to unique values.

    – Ge3ng
    Mar 10 at 6:27
















Can you post your manifest entry for the BroadcastReceiver that works

– Ge3ng
Mar 8 at 21:10






Can you post your manifest entry for the BroadcastReceiver that works

– Ge3ng
Mar 8 at 21:10














@Ge3ng see update in the post.

– aleksey_chugaev
Mar 9 at 2:19





@Ge3ng see update in the post.

– aleksey_chugaev
Mar 9 at 2:19













are both of these intents used? You may have a conflict of ids

– Ge3ng
Mar 9 at 19:32





are both of these intents used? You may have a conflict of ids

– Ge3ng
Mar 9 at 19:32













No, only one of them is used at the same time.

– aleksey_chugaev
Mar 10 at 6:26





No, only one of them is used at the same time.

– aleksey_chugaev
Mar 10 at 6:26













Try changing the 0 in you PendingIntents to unique values.

– Ge3ng
Mar 10 at 6:27





Try changing the 0 in you PendingIntents to unique values.

– Ge3ng
Mar 10 at 6:27












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070741%2flocationmanager-addproximityalert-throws-illegalargumentexceptionpending%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070741%2flocationmanager-addproximityalert-throws-illegalargumentexceptionpending%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved