Actually we cant use alertdialog on Service, Alert can be done through Activity only, so the better idea is call the activity from service class.
Use this on service class:
@Override
public void onReceive(Context context, Intent intent) {
Intent trIntent = new Intent("android.intent.action.MAIN");
trIntent.setClass(context, com.Ss.controls.YourDialog.class);
trIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(trIntent);
}
and Create an activity class:
public class YourDialog extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
Context ctx = this;
final AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
alert.setTitle("Message");
alert.setMessage("checking");
alert.setPositiveButton("Accept",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton)
{
}});
alert.create();
alert.show();
}
}
1 comments:
on service override... is not allowing
if we remove it then process is "unfortunately stopped "..
or it shows .. error"cant override on supper class"
please help me..
Post a Comment