android - I have added FLAG_ACTIVITY_NEW_TASK flag, but I still get "outside of an Activity context requires" error -


I still get the error when I invoke "requires an activity reference out startActivity () Calling FLAG_ACTIVITY_NEW_TASK flag" PublicParFun.ShareAPP (getApplicationContext ());.? I have added FLAG_ACTIVITY_NEW_TASK flag

Btw, PublicParFun.ShowMainUI (getApplicationContext ()) can work well, why

CallerMin.java < / Strong>

Package UI; Import info.dodata.callernametalker.R; Import android App Importroid.os.Bundle; Import android.view.View; Import android.view.View.OnClickListener; Import bll.PublicParFun; Public class caller enhances activity {@ override protected void creatives (bundle saved instanestate) {super.Nought (savedinstenstate); SetContentView (R.layout.caller_main); SetButtons (); } Private void SetButtons () {findViewById (R.id.btnSettings) .setOnClickListener (New OnClickListener () {@Override public void onClick (View v) {PublicParFun.ShowMainUI (getApplicationContext ());}}); findViewById (R.id.btnShare) .setOnClickListener (New OnClickListener () {@Override public void onClick (View v) {PublicParFun.ShareAPP (getApplicationContext ());}}); FindViewById (R.id.btnClose) .setOnClickListener (New OnClickListener () {@Override Public Zero onClick (see v) {Finish (;)}}); }}

publicParFun.java

  package bll; Public Square PublicParFun {Public Stable Zero ShowMainUI (reference myContext) {intent = intent (new intent)) SetClass (myContext, ui.CallerMain.class); Intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK | Int'lFLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); MyContext.startActivity; } Public steady zero ShareAPP (reference myContext) {intention intended = new intent (Intent.ACTION_SEND); Intent.setType ("text / plain"); Intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK | Int'lFLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); Intent.putExtra (Intent.EXTRA_TITLE, myContext.getString (R.string.ShareTitle)); Intent.putExtra (Intent.EXTRA_SUBJECT, myContext.getString (R.string.ShareTitle)); Intent.putExtra (Intent.EXTRA_TEXT, myContext.getString (R.string.ShareContent)); Try {MyContextkstartActivity (IntentkcreateChooser (mean, myContext.getString (R.string.defautlClient));} catch (android.content.ActivityNotFoundException ex) {Toast.makeText (myContext, myContext.getString (R.string .defautlNoClient), toast.LENGTH_SHORT) .show ();}}}}  

In the caller-Man activity class

inside getApplicationContext () instead of

  public on the phone. GetApplicationContext ());  

CallerMain.this as

  PublicParFun.ShowMainUI (CallerMain.This);  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -