Android development, I inserted a button in my activity, if andriod market can not find the words to use Toast to prompt, in the use of the time there are some problems, the following code error is the Context cannot be Resolved to a variable
1234567 |
uri Uri = Uri.parse (
" market://details?id= "
+ getapplicationcontext (). Getpackagename ());
intent gotomarket =
new
intent (Intent.action_view, URI);
try
{
    
startactivity (gotomarket);
}
catch
(activitynotfoundexception e) {
    
toast.maketext (Activity.
this
,
" couldn ' t launch the market "
}
|
I tried the following call
Toast.maketext (This, "couldn t launch the market", Toast.length_long). Show ();
Then the developer tool hints the method Maketext (Context, charsequence, int) in the type Toast was not applicable for the arguments (new VIEW.O Nclicklistener () {}, String, int)
I used to use it, and I don't know how it's going to work.
Processing methods
After you have inherited the activity, use the following 2 ways
Toast.maketext (Classname.this, "couldn ' t launch the Market", Toast.length_long). Show ();
Or
Toast.maketext (Getapplicationcontext (), "couldn ' t launch the Market", Toast.length_long). Show ();
If your class inherits Fragment, use the following method
Toast.maketext (Getactivity (), "couldn ' t launch market", Toast.length_long). Show ();
Original address: http://www.itmmd.com/201411/153.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.
Android Toast Error Activity Context.this cannot be resolved to a variable