There are two things that can happen when you write a statement:
Toast.maketext (alarmactivity.this, "Alarm clock cancellation", toast.length_short);
In English in Google search what ' s difference between this and activity.this, finally have the result (in fact, they use Java in the back of the classname.this and this Before the search is activity.this, so there is no result, this should be flexible to improve their search ability.
In StackOverflow found the answer:
Http://stackoverflow.com/questions/10102151/whats-the-difference-between-this-and-activity-this
Intent Intent = new Intent (this, secondactivity.class);
Eclipse Error:the Method SetClass (context, Class) in the type Intent isn't applicable for the arguments (firstactivity.c Lickevent, Class)
Intent Intent = new Intent (Firstactivity.this, secondactivity)
This is refers to your the current object. In your case your must have implemented the intent in a inner class clickevent, and thats what it points to.
Activity.this points to the instance's activity for you are currently in.
This is a reference to your current object, and in your case you must implement intent within the inner class clickevent, which points to clickevent rather than the activity you want to pass in.
Activity.this points to an instance of the activity name that you have filled out, and is also a reference.
In fact, this is the basis of Java, I have forgotten.
This is not a problem to use directly in an activity as the current object, and when this is used in an anonymous inner class, the current object becomes the inner class of new, and what you pass in will be activity.this if it is the whole activity.
Button B.setnegativebutton (R.string.cancel, New Dialoginterface.onclicklistener () {public
void OnClick ( Dialoginterface dialog, int which) {
toast.maketext (alarmactivity.this, "alarm clock starts after 5 seconds", Toast.length_short);
};
So in this case you need to specify which activity, the toast statement moved outside, delete alarmactivity also line.
So still is the netizen suggests, all use into activity.this, clear.
The above is the Android this and activity.this the difference of data collation, follow-up continue to supplement the relevant information thank you for your support of this site!