List of usage examples for android.content Intent getParcelableArrayListExtra
public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name)
From source file:org.amahi.anywhere.service.UploadService.java
@Override public int onStartCommand(@Nullable Intent intent, int flags, int startId) { if (intent != null && intent.hasExtra(Intents.Extras.IMAGE_URIS)) { if (isAutoUploadEnabled()) { ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intents.Extras.IMAGE_URIS); for (Uri uri : uris) { String imagePath = queryImagePath(uri); if (imagePath != null) { UploadFile uploadFile = uploadQueueDbHelper.addNewImagePath(imagePath); if (uploadFile != null && uploadManager != null) uploadManager.add(uploadFile); }/*from w w w. j a va 2 s . com*/ } } } if (isAutoUploadEnabled()) { if (isUploadAllowed()) { connectToServer(); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { NetConnectivityJob.scheduleJob(this); } } } return super.onStartCommand(intent, flags, startId); }
From source file:se.team05.service.MediaService.java
/** * This is called by the system when the system is about to start. It gets a * reference to the telephony manager, creates a phone state listener, * initiates a notification and then loads and prepares the media player * asynchronously./*from w ww . j av a 2 s.c o m*/ */ @Override public int onStartCommand(Intent intent, int flags, int startId) { telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); phoneStateListener = new MediaServicePhoneStateListener(this); currentTrackIndex = 0; playList = intent.getParcelableArrayListExtra(DATA_PLAYLIST); currentTrack = playList.get(currentTrackIndex); initNotification(); if (intent.getAction().equals(ACTION_PLAY)) { if (!mediaPlayer.isPlaying()) { mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setOnPreparedListener(this); initTrack(currentTrack); } } return START_STICKY; }
From source file:com.amaze.filemanager.asynchronous.services.ZipService.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { String mZipPath = intent.getStringExtra(KEY_COMPRESS_PATH); ArrayList<HybridFileParcelable> baseFiles = intent.getParcelableArrayListExtra(KEY_COMPRESS_FILES); File zipFile = new File(mZipPath); mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (!zipFile.exists()) { try {//from www. j av a 2 s . c o m zipFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference() .getCurrentUserColorPreferences(this, sharedPreferences).accent; Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small); customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big); Intent stopIntent = new Intent(KEY_COMPRESS_BROADCAST_CANCEL); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_zip_box_grey600_36dp, getString(R.string.stop_ftp), stopPendingIntent); mBuilder = new NotificationCompat.Builder(this, NotificationConstants.CHANNEL_NORMAL_ID) .setSmallIcon(R.drawable.ic_zip_box_grey600_36dp).setContentIntent(pendingIntent) .setCustomContentView(customSmallContentViews).setCustomBigContentView(customBigContentViews) .setCustomHeadsUpContentView(customSmallContentViews) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setOngoing(true) .setColor(accentColor); NotificationConstants.setMetadata(this, mBuilder, NotificationConstants.TYPE_NORMAL); startForeground(NotificationConstants.ZIP_ID, mBuilder.build()); initNotificationViews(); super.onStartCommand(intent, flags, startId); super.progressHalted(); asyncTask = new CompressAsyncTask(this, baseFiles, mZipPath); asyncTask.execute(); // If we get killed, after returning from here, restart return START_STICKY; }
From source file:com.tangyu.component.service.sync.TYSyncService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) return;//from ww w . j a v a2 s .com if (!intent.hasExtra(INTENT_CONFIG)) { throw new NullPointerException( "Not found the key of INTENT_DATA in intent extra, It's couldn't be null"); } mConfig = intent.getParcelableExtra(INTENT_CONFIG); mData = intent.getParcelableArrayListExtra(INTENT_DATA); if (null == mData) { mData = new LinkedList(); } if (!isHandleIntent(intent)) return; onPreExecute(mConfig, mData); TYResponseResult responseResult = executeByModel(mConfig, mData); onPostExecute(responseResult); Intent responseIntent = new Intent(ACTION_TYSYNC_RESPONSE); responseIntent.putExtra(INTENT_RESPONSE_SUCCESS, responseResult.isSuccess); responseIntent.putExtra(INTENT_RESPONSE_CONTENT, responseResult.content); sendBroadcast(responseIntent); // Util.v("Action = " + ACTION_TYSYNC_RESPONSE); }
From source file:org.gnucash.android.ui.budget.BudgetFormFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_EDIT_BUDGET_AMOUNTS) { if (resultCode == Activity.RESULT_OK) { ArrayList<BudgetAmount> budgetAmounts = data .getParcelableArrayListExtra(UxArgument.BUDGET_AMOUNT_LIST); if (budgetAmounts != null) { mBudgetAmounts = budgetAmounts; toggleAmountInputVisibility(); }//ww w . j a v a2 s .co m return; } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.readystatesoftware.android.geras.mqtt.GerasMqttService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { String host = intent.getStringExtra(EXTRA_HOST); String apiKey = intent.getStringExtra(EXTRA_API_KEY); ArrayList<GerasSensorConfig> monitors = intent.getParcelableArrayListExtra(EXTRA_SENSOR_MONITORS); for (GerasSensorConfig m : monitors) { mSensorMonitorMap.put(m.getSensorType(), m); }/* w ww.j ava2s. co m*/ mLocationMonitor = intent.getParcelableExtra(EXTRA_LOCATION_MONTITOR); mNotificationTarget = (Class) intent.getSerializableExtra(EXTRA_NOTIFICATION_TARGET_CLASS); sIsRunning = true; showNotification(); connect(host, apiKey); return Service.START_STICKY; }
From source file:com.groupme.sdk.activity.GroupCreateActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == AuthorizeActivity.REQUEST_LOGIN && (resultCode == AuthorizeActivity.LOGIN_FAILED || resultCode == 0)) { finish();//from w w w . j a v a 2 s . c o m } if (requestCode == AddContactActivity.REQUEST_CONTACTS_SELECT && resultCode == AddContactActivity.CONTACTS_SELECTED) { mContacts = data.getParcelableArrayListExtra("contacts"); Log.d(Constants.LOG_TAG, "Contacts selected: " + mContacts.size()); setListData(); } }
From source file:com.amaze.carbonfilemanager.services.ZipTask.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { Bundle b = new Bundle(); String path = intent.getStringExtra(KEY_COMPRESS_PATH); ArrayList<BaseFile> baseFiles = intent.getParcelableArrayListExtra(KEY_COMPRESS_FILES); File zipFile = new File(path); mZipPath = PreferenceManager.getDefaultSharedPreferences(this).getString(PreferenceUtils.KEY_PATH_COMPRESS, path);//from www. ja v a 2 s .co m mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (!mZipPath.equals(path)) { mZipPath.concat(mZipPath.endsWith("/") ? (zipFile.getName()) : ("/" + zipFile.getName())); } if (!zipFile.exists()) { try { zipFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } mBuilder = new NotificationCompat.Builder(this); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); mBuilder.setContentIntent(pendingIntent); mBuilder.setContentTitle(getResources().getString(R.string.compressing)) .setSmallIcon(R.drawable.ic_zip_box_grey600_36dp); startForeground(Integer.parseInt("789" + startId), mBuilder.build()); b.putInt("id", startId); b.putParcelableArrayList(KEY_COMPRESS_FILES, baseFiles); b.putString(KEY_COMPRESS_PATH, mZipPath); new DoWork().execute(b); // If we get killed, after returning from here, restart return START_STICKY; }
From source file:com.germainz.identiconizer.services.IdenticonCreationService.java
@Override protected void onHandleIntent(Intent intent) { startForeground(SERVICE_NOTIFICATION_ID, createNotification()); // If a predefined contacts list is provided, use it directly. // contactsList is set when this service is started from ContactsListActivity. if (intent.hasExtra("contactsList")) { ArrayList<ContactInfo> contactsList = intent.getParcelableArrayListExtra("contactsList"); processContacts(contactsList);//from ww w . jav a 2 s .com } else { // If updateExisting is set to false, only contacts without a picture will get a new one. // Otherwise, even those that have an identicon set will get a new one. The latter is useful // when changing identicon styles, but is a waste of time when we're starting this service // after a new contact has been added. In that case, we just want the new contact to get his // identicon. boolean updateExisting = intent.getBooleanExtra("updateExisting", true); processContacts(updateExisting); } if (mUpdateErrors.size() > 0 || mInsertErrors.size() > 0) createNotificationForError(); LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("CONTACTS_UPDATED")); getContentResolver().notifyChange(ContactsContract.Data.CONTENT_URI, null); stopForeground(true); }
From source file:cn.com.mark.multiimage.core.PreviewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_preview); mTextTitle = (TextView) findViewById(R.id.title); mTextInfo = (TextView) findViewById(R.id.text_info); mTextSend = (TextView) this.findViewById(R.id.send); mCheckOrigrnal = (CheckBox) findViewById(R.id.select_original1); mCheckOn = (CheckBox) findViewById(R.id.select_on); mPager = (ViewPager) findViewById(R.id.pager); findViewById(R.id.back).setOnClickListener(new View.OnClickListener() { @Override//w w w . j av a 2 s . c om public void onClick(View arg0) { finish(); } }); mTextSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { submit(); } }); Intent intent = this.getIntent(); if (intent != null) { isPerViewMode = intent.getBooleanExtra("preview", false); } if (isPerViewMode) { mDatas = new ArrayList<ImageEntity>(sResult); mPositionInAll = 0; } else { mDatas = intent.getParcelableArrayListExtra("action-data"); mPositionInAll = sPosotion; } updateTitle(); updateCheckStatus(); updateSendBtn(); updateOrgrnalSize(); mCheckOrigrnal.setChecked(isOriginal); mCheckOrigrnal.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { isOriginal = isChecked; updateOrgrnalSize(); } }); mPager.setAdapter(new ImagePagerAdapter(getSupportFragmentManager())); mPager.setOnPageChangeListener(new OnPageChangeListener() { public void onPageScrollStateChanged(int arg0) { } public void onPageScrolled(int arg0, float arg1, int arg2) { } public void onPageSelected(int arg0) { mPositionInAll = arg0; updateTitle(); updateCheckStatus(); updateOrgrnalSize(); } }); mPager.setCurrentItem(mPositionInAll); mCheckOn.setOnCheckedChangeListener(lisChecked); }