List of usage examples for android.content BroadcastReceiver BroadcastReceiver
public BroadcastReceiver()
From source file:com.rajat.e_subzi.gcm.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gcm); context = MainActivity.this; mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override//from www. jav a2s . co m public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; mInformationTextView = (TextView) findViewById(R.id.informationTextView); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.groksolutions.grok.mobile.instance.InstanceDetailPageFragment.java
public InstanceDetailPageFragment() { _metricDataChangedReceiver = new BroadcastReceiver() { @Override// w w w .j a va 2s.co m public void onReceive(Context context, Intent intent) { reloadChartData(); } }; _annotationChangedReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { reloadChartData(); } }; }
From source file:asia.covisoft.goom.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override/*from w ww . j a v a2s . c o m*/ public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; mInformationTextView = (TextView) findViewById(R.id.informationTextView); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.nadmm.airports.library.LibraryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarTitle("Library", null); mReceivers = new HashMap<>(); mReceiver = new BroadcastReceiver() { @Override//from w w w . ja v a2s . c om public void onReceive(Context context, Intent intent) { String category = intent.getStringExtra(LibraryService.CATEGORY); BroadcastReceiver receiver = mReceivers.get(category); if (receiver != null) { receiver.onReceive(context, intent); } // Show the PDF here as the Fragment requesting it may be paused String action = intent.getAction(); if (action.equals(LibraryService.ACTION_GET_BOOK)) { String path = intent.getStringExtra(LibraryService.PDF_PATH); mPending = false; if (path != null) { SystemUtils.startPDFViewer(LibraryActivity.this, path); } } } }; mFilter = new IntentFilter(); mFilter.setPriority(10); mFilter.addAction(LibraryService.ACTION_CHECK_BOOKS); mFilter.addAction(LibraryService.ACTION_GET_BOOK); mFilter.addAction(LibraryService.ACTION_DOWNLOAD_PROGRESS); SQLiteDatabase db = getDatabase(DatabaseManager.DB_LIBRARY); SQLiteQueryBuilder builder = new SQLiteQueryBuilder(); builder.setTables(DatabaseManager.BookCategories.TABLE_NAME); Cursor c = builder.query(db, new String[] { "*" }, null, null, null, null, DatabaseManager.BookCategories._ID); populateTabs(c); //setBackgroundTask( new LibraryCategoryTask() ).execute( "" ); }
From source file:com.opensesame.opensesamedoor.GCMReceiver.GCMReceiverMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gcm_receiver_activity_main); mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override//w w w. j a va 2s .c o m public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; mInformationTextView = (TextView) findViewById(R.id.informationTextView); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.konsula.app.gcm.MainActivityTest.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_test); //mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override/* w w w. j a v a 2 s . c o m*/ public void onReceive(Context context, Intent intent) { //mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(AppConstant.SENT_TOKEN_TO_SERVER, false); /*if (sentToken) { mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { mInformationTextView.setText(getString(R.string.token_error_message)); }*/ } }; mInformationTextView = (TextView) findViewById(R.id.informationTextView); registerReceiver(); if (checkPlayServices()) { Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.dododev.sailingcompetition.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override/*w w w .j av a2 s .c o m*/ public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(Constants.SENT_TOKEN_TO_SERVER, false); if (sentToken) { mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; mInformationTextView = (TextView) findViewById(R.id.informationTextView); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.hulhack.quandrum.wireframes.gcm.GcmActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gcm); setTitle("GCM Registration"); circularProgressButton = (CircularProgressButton) findViewById(R.id.btnWithText); circularProgressButton.setIndeterminateProgressMode(true); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override/*from w w w . ja va 2s .co m*/ public void onReceive(Context context, Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); /*Intent i = new Intent(GcmActivity.this,NavActivity.class); startActivity(i);*/ circularProgressButton.setProgress(100); finish(); /* if (sentToken) { mInformationTextView.setText("Finishing up..."); } else { mInformationTextView.setText("Oops!"); }*/ } }; if (checkPlayServices()) { // Start IntentService to register this application with GCM. Log.e("REG", "Start Reg Service"); Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.nadmm.airports.wx.WxTextFragmentBase.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(false);//from w w w . j av a 2 s . com mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(mAction) && mPendingRow != null) { TextView tv = (TextView) mPendingRow.findViewById(R.id.text); String label = tv.getText().toString(); String path = intent.getStringExtra(NoaaService.RESULT); Intent viewer = new Intent(getActivity(), TextFileViewActivity.class); viewer.putExtra(TextFileViewActivity.FILE_PATH, path); viewer.putExtra(TextFileViewActivity.TITLE_TEXT, getTitle()); viewer.putExtra(TextFileViewActivity.LABEL_TEXT, label); getActivity().startActivity(viewer); setProgressBarVisible(false); mPendingRow = null; } } }; mFilter = new IntentFilter(); mFilter.addAction(mAction); }
From source file:com.szanata.cordova.phonestatechangelistener.PhoneStateChangeListener.java
/** * creates a new BroadcastReceiver to listen whether the Telephony State changes */// ww w .j a v a 2 s . co m public void startPhoneListener(final CallbackContext callbackContext) { if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) { String state = intent.hasExtra(TelephonyManager.EXTRA_STATE) ? intent.getStringExtra(TelephonyManager.EXTRA_STATE) : NONE; String number = ""; if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); } final JSONObject data = new JSONObject(); try { data.put("state", state); data.put("number", number); callbackContext.success(data); } catch (final JSONException e) { callbackContext.error(e.getMessage()); } } } }; this.context.registerReceiver(this.receiver, new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED)); } }