List of usage examples for android.content BroadcastReceiver BroadcastReceiver
public BroadcastReceiver()
From source file:com.supremainc.biostar2.user.UserListFragment.java
protected void registerBroadcast() { if (mReceiver == null) { mReceiver = new BroadcastReceiver() { @Override/*from ww w. j a v a2 s .c o m*/ public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (mIsDestroy) { return; } if (action.equals(Setting.BROADCAST_USER)) { User user = (User) getExtraData(Setting.BROADCAST_USER, intent); if (user != null) { if (mUserAdapter.modifyItem(user)) { return; } } if (isResumed()) { mUserAdapter.getItems(mSearchText); } else { mIsDataReceived = false; } } else if (action.equals(Setting.BROADCAST_REROGIN)) { applyPermission(); } } }; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Setting.BROADCAST_USER); intentFilter.addAction(Setting.BROADCAST_REROGIN); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mReceiver, intentFilter); } }
From source file:com.mozilla.SUTAgentAndroid.SUTAgentAndroid.java
private void monitorBatteryState() { battReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { StringBuilder sb = new StringBuilder(); int rawlevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); // charge level from 0 to scale inclusive int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); // Max value for charge level int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1); int health = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, -1); boolean present = intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false); int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); //0 if the device is not plugged in; 1 if plugged into an AC power adapter; 2 if plugged in via USB. // int voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1); // voltage in millivolts nBatteryTemp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1); // current battery temperature in tenths of a degree Centigrade // String technology = intent.getStringExtra(BatteryManager.EXTRA_TECHNOLOGY); nChargeLevel = -1; // percentage, or -1 for unknown if (rawlevel >= 0 && scale > 0) { nChargeLevel = (rawlevel * 100) / scale; }// ww w . j a v a 2 s.c o m if (plugged > 0) sACStatus = "ONLINE"; else sACStatus = "OFFLINE"; if (present == false) sb.append("NO BATTERY"); else { if (nChargeLevel < 10) sb.append("Critical"); else if (nChargeLevel < 33) sb.append("LOW"); else if (nChargeLevel > 80) sb.append("HIGH"); } if (BatteryManager.BATTERY_HEALTH_OVERHEAT == health) { sb.append("Overheated "); sb.append((((float) (nBatteryTemp)) / 10)); sb.append("(C)"); } else { switch (status) { case BatteryManager.BATTERY_STATUS_UNKNOWN: // old emulator; maybe also when plugged in with no battery if (present == true) sb.append(" UNKNOWN"); break; case BatteryManager.BATTERY_STATUS_CHARGING: sb.append(" CHARGING"); break; case BatteryManager.BATTERY_STATUS_DISCHARGING: sb.append(" DISCHARGING"); break; case BatteryManager.BATTERY_STATUS_NOT_CHARGING: sb.append(" NOTCHARGING"); break; case BatteryManager.BATTERY_STATUS_FULL: sb.append(" FULL"); break; default: if (present == true) sb.append("Unknown"); break; } } sPowerStatus = sb.toString(); } }; IntentFilter battFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); registerReceiver(battReceiver, battFilter); }
From source file:com.dileepindia.cordova.sms.SMSPlugin.java
protected void createIncomingSMSReceiver() { Context ctx = this.cordova.getActivity(); this.mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Log.d("SMSPlugin", "onRecieve: " + action); if ("android.provider.Telephony.SMS_RECEIVED".equals(action)) { if (SMSPlugin.this.mIntercept) { abortBroadcast();//from www . ja v a2 s.co m } Bundle bundle = intent.getExtras(); if (bundle != null) { Object[] pdus = (Object[]) bundle.get("pdus"); if (pdus.length != 0) { for (int i = 0; i < pdus.length; i++) { SmsMessage sms = SmsMessage.createFromPdu((byte[]) pdus[i]); JSONObject json = SMSPlugin.this.getJsonFromSmsMessage(sms); SMSPlugin.this.onSMSArrive(json); } } } } } }; String[] filterstr = { "android.provider.Telephony.SMS_RECEIVED" }; for (int i = 0; i < filterstr.length; i++) { IntentFilter filter = new IntentFilter(filterstr[i]); filter.setPriority(100); ctx.registerReceiver(this.mReceiver, filter); Log.d("SMSPlugin", "broadcast receiver registered for: " + filterstr[i]); } }
From source file:com.rareventure.gps2.GpsTrailerService.java
@Override public void onCreate() { Log.d(TAG, "GPS Service Startup"); //android.os.Debug.waitForDebugger(); //FODO 1 IXME DISABLE! Nammu.init(this); //reset all flags notificationFlags = 0;/*from w w w . j a v a2 s. c o m*/ updateNotification(FLAG_GPS_ENABLED, true); GTG.addGTGEventListener(gtgEventListener); //read isCollectData first from shared prefs and if its false, quit immediately //we don't want to notify the user that we ran for any reason if this is false // (for example the db was corrupted) GTG.prefSet.loadAndroidPreferencesFromSharedPrefs(this); //co: we initially don't want to do anything if the user is unlicensed, // just find out how much piracy is a problem if (!GTG.prefs.isCollectData) //|| GTGEvent.ERROR_UNLICENSED.isOn) { turnOffNotification(); stopSelf(); return; } GTG.initRwtm.registerWritingThread(); try { try { GTG.requireInitialSetup(this, true); GTG.requirePrefsLoaded(this); if (!GTG.requireNotInRestore()) { updateNotification(FLAG_IN_RESTORE, true); stopSelf(); return; } Intent i = GTG.requireNotTrialWhenPremiumIsAvailable(this); if (i != null) { turnOffNotification(); stopSelf(); return; } if (!GTG.requireNotTrialExpired()) { updateNotification(FLAG_TRIAL_EXPIRED, true); stopSelf(); return; } if (!GTG.requireSdcardPresent(this)) { updateNotification(FLAG_ERROR_SDCARD_NOT_MOUNTED, true); stopSelf(); return; } if (!GTG.requireSystemInstalled(this)) { stopSelf(); return; } if (GTG.requireDbReady() != GTG.REQUIRE_DB_READY_OK) { updateNotification(FLAG_ERROR_DB_PROBLEM, true); stopSelf(); return; } GTG.requireEncrypt(); } finally { GTG.initRwtm.unregisterWritingThread(); } updateNotification(FLAG_COLLECT_ENABLED, true); //co because we don't want gps2data files in the root directory of sdcard. they take up too much space // SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); // File dataFile = new File(Environment.getExternalStorageDirectory(), "gps2data"+sdf.format(new Date())+".txt"); File dataFile = null; gpsManager = new GpsTrailerManager(dataFile, this, TAG, this.getMainLooper()); // gpsManager = new GpsTrailerManager(null, this, TAG, // this.getMainLooper()); //note that there is no way to receive the current status of the battery //However, the battery receiver will get a notification as soon as its registered // to the current status of the battery batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { float batteryLeft = ((float) intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)) / intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); /* ttt_installer:remove_line */Log.d(GTG.TAG, "Received battery info, batteryLeft: " + batteryLeft); int status = intent.getIntExtra("status", BatteryManager.BATTERY_STATUS_UNKNOWN); if (batteryLeft < GTG.prefs.minBatteryPerc && (status == BatteryManager.BATTERY_STATUS_DISCHARGING || status == BatteryManager.BATTERY_STATUS_UNKNOWN)) { updateNotification(FLAG_BATTERY_LOW, true); GTG.alert(GTGEvent.ERROR_LOW_BATTERY); } else updateNotification(FLAG_BATTERY_LOW, false); //we wait until now to finish startup //because otherwise if the battery is low //and we are awoken for some other event, we would otherwise show our icon for //a brief period before we get the battery is low event updateNotification(FLAG_FINISHED_STARTUP, true); //just a hack, a reasonable place to check if the trial version has expired checkTrialExpired(); } }; IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); registerReceiver(batteryReceiver, batteryLevelFilter); gpsManager.start(); } catch (Exception e) { shutdownWithException(e); ACRA.getErrorReporter().handleException(e); } }
From source file:com.example.accountkitsample.MainActivity.java
private AccountKitConfiguration.AccountKitConfigurationBuilder createAccountKitConfiguration( final LoginType loginType) { AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder( loginType, getResponseType()); final Switch titleTypeSwitch = (Switch) findViewById(R.id.title_type_switch); final Switch stateParamSwitch = (Switch) findViewById(R.id.state_param_switch); final Switch facebookNotificationsSwitch = (Switch) findViewById(R.id.facebook_notification_switch); final Switch useManualWhiteListBlacklist = (Switch) findViewById(R.id.whitelist_blacklist_switch); final Switch readPhoneStateSwitch = (Switch) findViewById(R.id.read_phone_state_switch); final Switch receiveSMS = (Switch) findViewById(R.id.receive_sms_switch); if (titleTypeSwitch != null && titleTypeSwitch.isChecked()) { configurationBuilder.setTitleType(AccountKitActivity.TitleType.APP_NAME); }/*from w w w. j a v a 2 s . co m*/ if (advancedUISwitch != null && advancedUISwitch.isChecked()) { if (isReverbThemeSelected()) { if (switchLoginTypeReceiver == null) { switchLoginTypeReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { final String loginTypeString = intent.getStringExtra(ReverbUIManager.LOGIN_TYPE_EXTRA); if (loginTypeString == null) { return; } final LoginType loginType = LoginType.valueOf(loginTypeString); if (loginType == null) { return; } onLogin(loginType); } }; LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver( switchLoginTypeReceiver, new IntentFilter(ReverbUIManager.SWITCH_LOGIN_TYPE_EVENT)); } configurationBuilder.setAdvancedUIManager( new ReverbUIManager(confirmButton, entryButton, loginType, textPosition, selectedThemeId)); } else { configurationBuilder.setAdvancedUIManager( new AccountKitSampleAdvancedUIManager(confirmButton, entryButton, textPosition, loginType)); } } if (stateParamSwitch != null && stateParamSwitch.isChecked()) { initialStateParam = UUID.randomUUID().toString(); configurationBuilder.setInitialAuthState(initialStateParam); } if (facebookNotificationsSwitch != null && !facebookNotificationsSwitch.isChecked()) { configurationBuilder.setFacebookNotificationsEnabled(false); } if (selectedThemeId > 0) { configurationBuilder.setTheme(selectedThemeId); } if (useManualWhiteListBlacklist != null && useManualWhiteListBlacklist.isChecked()) { final String[] blackList = getResources().getStringArray(R.array.blacklistedSmsCountryCodes); final String[] whiteList = getResources().getStringArray(R.array.whitelistedSmsCountryCodes); configurationBuilder.setSMSBlacklist(blackList); configurationBuilder.setSMSWhitelist(whiteList); } if (readPhoneStateSwitch != null && !(readPhoneStateSwitch.isChecked())) { configurationBuilder.setReadPhoneStateEnabled(false); } if (receiveSMS != null && !receiveSMS.isChecked()) { configurationBuilder.setReceiveSMS(false); } return configurationBuilder; }
From source file:com.facebook.samples.loginsample.accountkit.AccountKitLoginActivity.java
private AccountKitConfiguration.AccountKitConfigurationBuilder createAccountKitConfiguration( final LoginType loginType) { AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder( loginType, getResponseType()); final Switch titleTypeSwitch = (Switch) findViewById(R.id.title_type_switch); final Switch stateParamSwitch = (Switch) findViewById(R.id.state_param_switch); final Switch facebookNotificationsSwitch = (Switch) findViewById(R.id.facebook_notification_switch); final Switch useManualWhiteListBlacklist = (Switch) findViewById(R.id.whitelist_blacklist_switch); final Switch readPhoneStateSwitch = (Switch) findViewById(R.id.read_phone_state_switch); final Switch receiveSMS = (Switch) findViewById(R.id.receive_sms_switch); if (titleTypeSwitch != null && titleTypeSwitch.isChecked()) { configurationBuilder.setTitleType(com.facebook.accountkit.ui.AccountKitActivity.TitleType.APP_NAME); }/*from ww w.j a v a 2s.co m*/ if (advancedUISwitch != null && advancedUISwitch.isChecked()) { if (isReverbThemeSelected()) { if (switchLoginTypeReceiver == null) { switchLoginTypeReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { final String loginTypeString = intent.getStringExtra(ReverbUIManager.LOGIN_TYPE_EXTRA); if (loginTypeString == null) { return; } final LoginType loginType = LoginType.valueOf(loginTypeString); if (loginType == null) { return; } onLogin(loginType); } }; LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver( switchLoginTypeReceiver, new IntentFilter(ReverbUIManager.SWITCH_LOGIN_TYPE_EVENT)); } configurationBuilder.setAdvancedUIManager( new ReverbUIManager(confirmButton, entryButton, loginType, textPosition, selectedThemeId)); } else { configurationBuilder.setAdvancedUIManager( new AccountKitSampleAdvancedUIManager(confirmButton, entryButton, textPosition, loginType)); } } if (stateParamSwitch != null && stateParamSwitch.isChecked()) { initialStateParam = UUID.randomUUID().toString(); configurationBuilder.setInitialAuthState(initialStateParam); } if (facebookNotificationsSwitch != null && !facebookNotificationsSwitch.isChecked()) { configurationBuilder.setFacebookNotificationsEnabled(false); } if (selectedThemeId > 0) { configurationBuilder.setTheme(selectedThemeId); } if (useManualWhiteListBlacklist != null && useManualWhiteListBlacklist.isChecked()) { final String[] blackList = getResources().getStringArray(R.array.blacklistedSmsCountryCodes); final String[] whiteList = getResources().getStringArray(R.array.whitelistedSmsCountryCodes); configurationBuilder.setSMSBlacklist(blackList); configurationBuilder.setSMSWhitelist(whiteList); } if (readPhoneStateSwitch != null && !(readPhoneStateSwitch.isChecked())) { configurationBuilder.setReadPhoneStateEnabled(false); } if (receiveSMS != null && !receiveSMS.isChecked()) { configurationBuilder.setReceiveSMS(false); } return configurationBuilder; }
From source file:com.quarterfull.newsAndroid.ssl.MemorizingTrustManager.java
void interact(final X509Certificate[] chain, CertificateException cause) throws CertificateException { /* prepare the MTMDecision blocker object */ MTMDecision choice = new MTMDecision(); final int myId = createDecisionId(choice); final String certMessage = certChainMessage(chain, cause); BroadcastReceiver decisionReceiver = new BroadcastReceiver() { public void onReceive(Context ctx, Intent i) { interactResult(i);/* w w w .j av a 2s .c om*/ } }; mContext.registerReceiver(decisionReceiver, new IntentFilter(DECISION_INTENT + "/" + mContext.getPackageName())); masterHandler.post(new Runnable() { public void run() { Intent ni = new Intent(mContext, MemorizingDialogFragment.class); ni.setData(Uri.parse(MemorizingTrustManager.class.getName() + "/" + myId)); Bundle bundle = new Bundle(); bundle.putString(DECISION_INTENT_APP, mContext.getPackageName()); bundle.putInt(DECISION_INTENT_ID, myId); bundle.putString(DECISION_INTENT_CERT, certMessage); DialogFragment dialog = new MemorizingDialogFragment(); dialog.setArguments(bundle); try { dialog.show(((FragmentActivity) getUI()).getSupportFragmentManager(), "NoticeDialogFragment"); } catch (Exception ex) { Log.e(TAG, "startActivity: " + ex); startActivityNotification(ni, certMessage); } } }); Log.d(TAG, "openDecisions: " + openDecisions); Log.d(TAG, "waiting on " + myId); try { synchronized (choice) { choice.wait(); } } catch (InterruptedException e) { e.printStackTrace(); } mContext.unregisterReceiver(decisionReceiver); Log.d(TAG, "finished wait on " + myId + ": " + choice.state); switch (choice.state) { case MTMDecision.DECISION_ALWAYS: storeCert(chain); case MTMDecision.DECISION_ONCE: break; default: throw (cause); } }
From source file:com.company.millenium.iwannask.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //GPS//from ww w. ja v a2s .c om locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationListener = new LocationListener() { public void onLocationChanged(Location location) { if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.removeUpdates(this); } } public void onStatusChanged(String string, int integer, Bundle bundle) { } public void onProviderEnabled(String string) { } public void onProviderDisabled(String string) { } }; if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1000, locationListener); } int delay = 30000; // delay for 30 sec. int period = 3000000; // repeat every 5.3min. Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.removeUpdates(locationListener); } } }, delay, period); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); Intent mIntent = getIntent(); URL = Constants.SERVER_URL; if (mIntent.hasExtra("url")) { myWebView = null; startActivity(getIntent()); String url = mIntent.getStringExtra("url"); URL = Constants.SERVER_URL + url; } CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); myWebView = (WebView) findViewById(R.id.webview); myWebView.getSettings().setGeolocationDatabasePath(this.getFilesDir().getPath()); myWebView.getSettings().setGeolocationEnabled(true); WebSettings webSettings = myWebView.getSettings(); webSettings.setUseWideViewPort(false); if (!DetectConnection.checkInternetConnection(this)) { webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); showNoConnectionDialog(this); } else { webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); } webSettings.setJavaScriptEnabled(true); myWebView.addJavascriptInterface(new webappinterface(this), "android"); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); myWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //location test webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); myWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { CookieSyncManager.getInstance().sync(); } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); // Ignore SSL certificate errors } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (Uri.parse(url).getHost().equals(Constants.HOST) || Uri.parse(url).getHost().equals(Constants.WWWHOST)) { // This is my web site, so do not override; let my WebView load // the page return false; } // Otherwise, the link is not for a page on my site, so launch // another Activity that handles URLs Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } }); myWebView.setWebChromeClient(new WebChromeClient() { public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } @Override public void onPermissionRequest(final PermissionRequest request) { Log.d(TAG, "onPermissionRequest"); runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { if (request.getOrigin().toString().equals("https://apprtc-m.appspot.com/")) { request.grant(request.getResources()); } else { request.deny(); } } }); } public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { // Double check that we don't have any existing callbacks if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; // Set up the take picture intent Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } // Set up the intent to get an existing image Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); // Set up the intents for the Intent chooser Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } }); // setContentView(myWebView); // myWebView.loadUrl(URL); myWebView.loadUrl(URL); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override 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); } }; //CookieManager mCookieManager = CookieManager.getInstance(); //Boolean hasCookies = mCookieManager.hasCookies(); //while(!hasCookies); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); //intent.putExtra("session", session); startService(intent); } Boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true); if (isFirstRun) { //show start activity startActivity(new Intent(MainActivity.this, MyIntro.class)); } //if (!isOnline()) // showNoConnectionDialog(this); getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit().putBoolean("isFirstRun", false).commit(); //Pull-to-refresh mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.container); mSwipeRefreshLayout.setOnRefreshListener(this); }