I want to pass a data from a service to a fragment . Here my code in the service
public void putInfo(){
Intent trIntent = new Intent("android.intent.action.MAIN");
trIntent.setClass(this,WelcomeActivity.class);
trIntent.putExtra("info", strengthAmplitude+"");
trIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(trIntent);
}
And then I want to use this data ("info") in my fragment (InfoFragment) like that
String msg = getActivity().getIntent().getExtras().getString("info");
I am getting errors.
E/AndroidRuntime(25036): java.lang.RuntimeException: Unable to start service
com.BackupAndTools.service.InfoService@41e6b498 with Intent {
cmp=com.BackupAndTools/.service.InfoService }:
android.content.ActivityNotFoundException: Unable to find explicit activity class
{com.BackupAndTools/com.BackupAndTools.views.InfoFragment}; have you declared this
activity in your AndroidManifest.xml?
while it is a fragment not an activity to be declared in AndroidManifets.xml !!