моему приложению необходимо установить несколько аварийных сигналов Мне хотелось бы показать пользовательский диалог при срабатывании тревоги.Как открыть пользовательский диалог при возникновении тревоги
мой класс приемник
package com.example.memopad;
import java.util.zip.Inflater;
import android.app.Dialog;
import android.app.FragmentManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class AlarmReceiver extends BroadcastReceiver{
String dato;
public Context context;
@Override
public void onReceive(Context context, Intent intent) {
dato=intent.getStringExtra("nome");
lanciaDialog();
//Toast toast =Toast.makeText(context, "Oggi e' il compleanno di " + dato , Toast.LENGTH_SHORT);
// toast.show();
}
public void lanciaDialog(){
DialogFragment dialog = new CustomDialogCumple();
dialog.show(getSupportFragmentManager(), "missiles");
}
}
мой класс CustomDialogCumple является
package com.example.memopad;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
public class CustomDialogCumple extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
builder.setView(inflater.inflate(R.layout.customdialogcumple, null));
builder.setMessage(R.string.cumple)
/*.setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
})*/
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
return builder.create();
}
}
У меня есть проблема в dialog.show (getSupportFragmentManager(), "ракеты");
Я использовал Dialogfragment в соответствии с гидом Google Есть ли у вас какой-либо намек на меня? Заранее спасибо
В чем проблема? Это ошибка времени выполнения/ошибка компиляции? есть ли журналы? – Kay