メイン アクティビティと単純なクラスがあります。メイン アクティビティにはダイアログ ボックス メソッドがあり、このメソッドを別のクラスから呼び出しています。
主な活動-
public class WishareActivity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
activity=this;
//handler to call alertmsg()method
alerthandler= new Handler() {
public void handleMessage(Message msg){
alertmsg();
}
};
layouthandler= new Handler() {
public void handleMessage(Message msg){
setContentView(R.layout .main);
}
};
}
//method to show the dialog box
public static void alertmsg()
{
AlertDialog.Builder alert = new AlertDialog.Builder(WishareActivity.activity);
alert.setTitle("Confirm");
alert.setMessage("abc");
alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
}
});
alert.setNegativeButton("Deny", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
Log.d("abc","alert alert");
AlertDialog s=alert.create();
s.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss( DialogInterface dialog) {
}
});
Log.d("abc1","alert alert");
alert.show();
Log.d("abc1","alert alert alert");
return;
}
connect.class
public class connect implements Runnable
{
public void run()
{
WishareActivity.layouthandler.sendEmptyMessage(0);
WishareActivity.alerthandler.sendEmptyMessage(0);
}
}
Logcatでその表示
abc : alert alert
abc1: alert alert
abc1 :alert alert alert
ログによると、メソッドは正しく呼び出されますが、ダイアログ ボックスは表示されません。
どんな助けでも大歓迎です