android


How to pass the extras to intent when the application gets launched using Alarm Manager?


In the application which i'm developing, i'm having an alarm manager which will launch the application in particular time. During this process, i'm passing a string as the part of intents as shown below.
Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage("Application Package Name");
String strName = "Preferences";
LaunchIntent.putExtra("STRING_NAME", strName);
context.startActivity(LaunchIntent);
It is opening the application. But in the when i do intent.getStringExtra("STRING_NAME"), in the onCreate() method of the Homescreen, the passed string value is not coming.
In this class i'm initializing the alarm manager for every 40 seconds as shown below in the onCreate method:
private static void SetScheduleSync(Context context) {
Intent downloader = new Intent(context, ScheduleSyncManager.class);
PendingIntent recurringDownload = PendingIntent.getBroadcast(context, 1000, downloader, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
int interval = 10000*4;
manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), interval, recurringDownload);
}
Inside the ScheduleSyncManager.class, i have written code to open up the application by passing the extras as the pert of intent. When the application opens up, i checking whether is there any extra data in the particular intent.
Here is the ScheduleManagerDeclaration:
public class ScheduleSyncManager extends WakefulBroadcastReceiver {
public Boolean IsCustomizingPresent = false;
String strName = "Preferences";
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Sync in the background has Started", Toast.LENGTH_SHORT).show();
performScheduleSync(context, intent);
}
public void performScheduleSync(Context context, Intent intent) {
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage("com.sap.rex.ui");
launchIntent.putExtra("STRING_NAME", strName);
launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(launchIntent);
}
And i'm calling the ScheduleManager from function SetScheduleSync() in Oncreate() method as i posted the code below.
Please help me with this. Is it possible to do like this?
Thanks.
Try the following:
LaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
P.S. It's a common practice to make the first letters of the instances lower case., i.e., not LaunchIntent but launchIntent.

Related Links

How to get Registration ID from C2DM Servers?
android ddms screen capture vertical size seems fixed at 1024
Stop Recording and Context
Android when to close database dilemma
Android - Proper way to wait for handler object to be created
How do you make these buttons?
Switching from full screen to not full screen pop/slide
How to sort SQLite database onCreate, as well as onResume, based on sharedpreference?
ImageView findViewById and setContent(R.layout.main) doesn't work
How to organize images (several) for use in Android app? [closed]
Ontouch event of OnTouchListener gets called twice in android
OMXCodec.cpp error compiling Gingerbread from codeaurora.org
No item is shown in ListView
Swipe Pages in Android
Android : Get view Reference to a Menu Item
Deleting Android SMS programmatically

Categories

HOME
cygwin
beautifulsoup
developer-tools
redux-form
phpmyadmin
google-spreadsheet
zend-framework
static
battery
components
error-handling
knitr
gradient
ms-access-2016
3d-reconstruction
square
settings
google-cloud-datalab
opengl-3
character
sendgrid-api-v3
mautic
supervisor
symmetricds
eip
coin3d
aws-sdk
google-content-api
squashfs
ckfinder
bulletphysics
angularjs-components
comparable
uitapgesturerecognizer
google-earth
scrollview
r-grid
dsx-desktop
contacts
reactjs.net
sharepoint-workflow
raft
sim-toolkit
kill
doc
pom.xml
user-defined-fields
mschart
manova
x-ray
page-replacement
java-websocket
rsa-archer-grc
android-instrumentation
usart
meteor-packages
mapxtreme
microstation
installshield-2010
lean
project-organization
ellucian-scribe
piracy-prevention
contentcontrol
spring-retry
sciruby
cgi-bin
slash
sony-lifelog-api
wso2greg
snoop
nsurlsessiondatatask
fits
qtwebengine
variadic-templates
beatsmusic
boost-program-options
machine-instruction
cbind
named-parameters
rcaller
alternate
dct
dot42
xmltodict
code-duplication
jeromq
cocoalibspotify-2.0
scringo
workitem
abstract-data-type
swfobject
curb
veracity
wcf-configuration
entity-attribute-value
denied
entitydatasource
umra
xui
presentation-layer
google-wave
product-management

Resources

Encrypt Message