List of usage examples for android.content Context BIND_AUTO_CREATE
int BIND_AUTO_CREATE
To view the source code for android.content Context BIND_AUTO_CREATE.
Click Source Link
From source file:com.wifi.brainbreaker.mydemo.spydroid.ui.HandsetFragment.java
@Override public void onResume() { super.onResume(); getActivity().bindService(new Intent(getActivity(), CustomHttpServer.class), mHttpServiceConnection, Context.BIND_AUTO_CREATE); getActivity().bindService(new Intent(getActivity(), CustomRtspServer.class), mRtspServiceConnection, Context.BIND_AUTO_CREATE); getActivity().registerReceiver(mWifiStateReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION)); }
From source file:com.hang.exoplayer.PlayActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Toast.makeText(this, "play modify playing address!", Toast.LENGTH_LONG).show(); setContentView(R.layout.activity_play); findViewById(R.id.ibtn_setting).setOnClickListener(this); mPlayControlView = (ImageButton) findViewById(R.id.ibtn_play_pause); mPlayControlView.setOnClickListener(this); mPlayAnimView = (ImageView) findViewById(R.id.iv_play_anim); mPreviousView = (ImageButton) findViewById(R.id.ibtn_previous); mNextView = (ImageButton) findViewById(R.id.ibtn_next); mPreviousView.setOnClickListener(this); mNextView.setOnClickListener(this); mDownloadView = (ImageButton) findViewById(R.id.ibtn_download); mPlayListView = (ImageButton) findViewById(R.id.ibtn_list); mDownloadView.setOnClickListener(this); mPlayListView.setOnClickListener(this); seekBar = (SeekBar) findViewById(R.id.seekbar); seekBar.setOnSeekBarChangeListener(this); playStatusReceiver = new PlayStatusReceiver(); Intent intent = new Intent(PlayActivity.this, PlayService.class); mPlayServiceConnection = new PlayServiceConnection(); bindService(intent, mPlayServiceConnection, Context.BIND_AUTO_CREATE); //for simper permission ,just apply it from start applyAccessPermission();/* w w w .ja v a2 s .c om*/ //get internet play addresses // new Thread() { // @Override // public void run() { // QueryLiveProgramList.getLiveAddress(QueryLiveProgramList.TYPE_MUZHI); // } // }.start(); }
From source file:com.christophergs.mbientbasic.ModuleFragmentBase.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Activity owner = getActivity();/*from w ww. j a va 2 s . co m*/ if (!(owner instanceof FragmentBus)) { throw new ClassCastException(String.format(Locale.US, "%s %s", owner.toString(), owner.getString(R.string.error_fragment_bus))); } fragBus = (FragmentBus) owner; owner.getApplicationContext().bindService(new Intent(owner, MetaWearBleService.class), this, Context.BIND_AUTO_CREATE); }
From source file:com.secupwn.aimsicd.ui.fragments.CellInfoFragment.java
@Override public void onResume() { super.onResume(); if (!mBound) { // Bind to LocalService Intent intent = new Intent(mContext, AimsicdService.class); mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }/*from ww w . j a v a 2s.com*/ // Refresh display if preference (pref_refresh_values) is not set to manual (0) // For automatic it is "1" and defined in: // CellTracker.java :: onSharedPreferenceChanged() if (CellTracker.REFRESH_RATE != 0) { timerHandler.postDelayed(timerRunnable, 0); Helpers.msgShort(mContext, mContext.getString(R.string.refreshing_every) + " " + TimeUnit.MILLISECONDS.toSeconds(CellTracker.REFRESH_RATE) + " " + mContext.getString(R.string.seconds)); } }
From source file:fm.libre.droid.LibreDroid.java
/** Called when the activity is first created. */ @Override/*from ww w.jav a 2 s .co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); libreServiceConn = new LibreServiceConnection(); bindService(new Intent(this, LibreService.class), libreServiceConn, Context.BIND_AUTO_CREATE); this.registerReceiver(new MediaButtonReceiver(), new IntentFilter(Intent.ACTION_MEDIA_BUTTON)); this.registerReceiver(new UIUpdateReceiver(), new IntentFilter("LibreDroidNewSong")); setContentView(R.layout.main); // Load settings final SharedPreferences settings = getSharedPreferences("LibreDroid", MODE_PRIVATE); username = settings.getString("Username", ""); password = settings.getString("Password", ""); final EditText usernameEntry = (EditText) findViewById(R.id.usernameEntry); final EditText passwordEntry = (EditText) findViewById(R.id.passwordEntry); usernameEntry.setText(username); passwordEntry.setText(password); final Button loginButton = (Button) findViewById(R.id.loginButton); loginButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Editor editor = settings.edit(); editor.putString("Username", usernameEntry.getText().toString()); editor.putString("Password", passwordEntry.getText().toString()); editor.commit(); LibreDroid.this.login(); } }); stations = new ArrayList<String>(); try { BufferedReader stationReader = new BufferedReader( new InputStreamReader(openFileInput("libredroid-custom-stations.conf"))); String station; while ((station = stationReader.readLine()) != null) { stations.add(station); } stationReader.close(); } catch (IOException ex) { Log.d("libredroid", ex.getMessage()); } // Add default stations if empty if (stations.isEmpty()) { String radioButtons[] = { "Folk", "Rock", "Metal", "Classical", "Pop", "Punk", "Jazz", "Blues", "Rap", "Ambient", "Add A Custom Station..." }; stations.addAll(Arrays.asList(radioButtons)); } setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, stations)); Button tagStation = (Button) findViewById(R.id.tagStationButton); tagStation.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.nextPage(); } }); Button loveStation = (Button) findViewById(R.id.loveStationButton); loveStation.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.tuneStation("user", username + "/loved"); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); } }); Button communityLoveStation = (Button) findViewById(R.id.communityStationButton); communityLoveStation.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.tuneStation("community", "loved"); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); } }); final ImageButton nextButton = (ImageButton) findViewById(R.id.nextButton); nextButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.next(); } }); final ImageButton prevButton = (ImageButton) findViewById(R.id.prevButton); prevButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.prev(); } }); final ImageButton playPauseButton = (ImageButton) findViewById(R.id.playPauseButton); playPauseButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.togglePause(); } }); final ImageButton saveButton = (ImageButton) findViewById(R.id.saveButton); saveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.save(); } }); final ImageButton loveButton = (ImageButton) findViewById(R.id.loveButton); loveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.love(); } }); final ImageButton banButton = (ImageButton) findViewById(R.id.banButton); banButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.ban(); } }); final Button addStationButton = (Button) findViewById(R.id.addStationButton); addStationButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.addStation(); } }); }
From source file:com.SecUpwN.AIMSICD.smsdetection.SmsDetector.java
public void startSmsDetection() { Intent intent = new Intent(tContext, AimsicdService.class); tContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); start();/* www . j a va 2 s . c o m*/ Log.i(TAG, "sms detection started"); }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.BlockListFragment.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); activity.runAfterLoad(new Runnable() { @Override/*from w w w.j av a 2 s .c o m*/ public void run() { activity.bindService(new Intent(activity, BlockchainServiceImpl.class), serviceConnection, Context.BIND_AUTO_CREATE); } }); }
From source file:com.aptoide.amethyst.ui.ScheduledDownloadsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { //Aptoide.getThemePicker().setAptoideTheme(this); super.onCreate(savedInstanceState); setContentView(getContentView());/*w ww. jav a 2 s . c om*/ bindViews(); mToolbar.setCollapsible(false); setSupportActionBar(mToolbar); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setTitle(getString(R.string.setting_schdwntitle)); lv = (ListView) findViewById(android.R.id.list); lv.setDivider(null); db = new AptoideDatabase(Aptoide.getDb()); bindService(new Intent(this, DownloadService.class), conn, Context.BIND_AUTO_CREATE); adapter = new CursorAdapter(this, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) { @Override public View newView(Context context, Cursor arg1, ViewGroup arg2) { return LayoutInflater.from(context).inflate(R.layout.row_sch_download, null); } @Override public void bindView(View convertView, Context arg1, Cursor c) { ScheduledDownload scheduledDownload = scheduledDownloadsMap.get(c.getLong(c.getColumnIndex("_id"))); // The child views in each row. CheckBox checkBoxScheduled; TextView textViewName; TextView textViewVersion; ImageView imageViewIcon; if (convertView.getTag() == null) { textViewName = (TextView) convertView.findViewById(R.id.name); textViewVersion = (TextView) convertView.findViewById(R.id.appversion); checkBoxScheduled = (CheckBox) convertView.findViewById(R.id.schDwnChkBox); imageViewIcon = (ImageView) convertView.findViewById(R.id.appicon); convertView.setTag(new Holder(textViewName, textViewVersion, checkBoxScheduled, imageViewIcon)); checkBoxScheduled.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v; ScheduledDownload schDownload = (ScheduledDownload) cb.getTag(); schDownload.setChecked(cb.isChecked()); } }); } // Reuse existing row view else { // Because we use a ViewHolder, we avoid having to call findViewById(). Holder viewHolder = (Holder) convertView.getTag(); checkBoxScheduled = viewHolder.checkBoxScheduled; textViewVersion = viewHolder.textViewVersion; textViewName = viewHolder.textViewName; imageViewIcon = viewHolder.imageViewIcon; } // Tag the CheckBox with the Planet it is displaying, so that we can // access the planet in onClick() when the CheckBox is toggled. checkBoxScheduled.setTag(scheduledDownload); // Display planet data checkBoxScheduled.setChecked(scheduledDownload.isChecked()); textViewName.setText(scheduledDownload.getName()); textViewVersion.setText(scheduledDownload.getVersion_name()); Glide.with(ScheduledDownloadsActivity.this).load(scheduledDownload.getIcon()).into(imageViewIcon); } }; getSupportLoaderManager().initLoader(0, null, this); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View item, int arg2, long arg3) { ScheduledDownload scheduledDownload = (ScheduledDownload) ((Holder) item.getTag()).checkBoxScheduled .getTag(); scheduledDownload.toggleChecked(); Holder viewHolder = (Holder) item.getTag(); viewHolder.checkBoxScheduled.setChecked(scheduledDownload.isChecked()); } }); if (getIntent().hasExtra(ARG_DOWNLOAD_ALL)) { ScheduledDownloadsDialog pd = new ScheduledDownloadsDialog(); pd.show(getSupportFragmentManager(), "installAllScheduled"); } lv.setAdapter(adapter); }
From source file:me.tassoevan.cordova.BackgroundPlugin.java
private void startService() { Activity context = cordova.getActivity(); Intent intent = new Intent(context, ForegroundService.class); if (isDisabled || isBind) { return;/*w ww. java 2 s. c o m*/ } context.bindService(intent, connection, Context.BIND_AUTO_CREATE); context.startService(intent); isBind = true; }
From source file:de.grundid.plusrad.MainActivity.java
private void connectToService() { Intent rService = new Intent(this, RecordingService.class); ServiceConnection sc = new ServiceConnection() { public void onServiceDisconnected(ComponentName name) { }/*from ww w . j av a 2 s.c o m*/ public void onServiceConnected(ComponentName name, IBinder service) { RecordingService.IRecordService rs = (RecordingService.IRecordService) service; int state = rs.getState(); if (state == RecordingService.STATE_RECORDING || state == RecordingService.STATE_PAUSED) { startActivity(new Intent(MainActivity.this, RecordingActivity.class)); } else { cleanupData(); } MainActivity.this.unbindService(this); // race? this says we no longer care } }; // This needs to block until the onServiceConnected (above) completes. // Thus, we can check the recording status before continuing on. bindService(rService, sc, Context.BIND_AUTO_CREATE); }