List of usage examples for android.content Intent getStringArrayExtra
public String[] getStringArrayExtra(String name)
From source file:com.commonsware.android.arXiv.SubarXiv.java
/** * Called when the activity is first created. */// w w w . j a v a 2s. c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.submain); Intent myIntent = getIntent(); name = myIntent.getStringExtra("keyname"); urls = myIntent.getStringArrayExtra("keyurls"); items = myIntent.getStringArrayExtra("keyitems"); shortItems = myIntent.getStringArrayExtra("keyshortitems"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mySourcePref = prefs.getInt("source", 0); ActionBar ab = getSupportActionBar(); ab.setTitle(name); ab.setDisplayHomeAsUpEnabled(true); ab.setHomeButtonEnabled(true); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(android.R.id.content, new SubarXivFragment()); ft.commit(); }
From source file:ar.uba.fi.splitapp.ChatRoomActivity.java
/** * Perform initialization of all fragments and loaders. * * @param bundle If the activity is being re-initialized after previously being shut down then * this Bundle contains the data it most recently supplied in * onSaveInstanceState(Bundle). Note: Otherwise it is null. */// ww w . j a v a2s .c o m @Override protected void onCreate(Bundle bundle) { FacebookManager.checkInit(this); super.onCreate(bundle); setContentView(R.layout.activity_chat_room); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Intent intent = getIntent(); mFriendId = intent.getStringArrayExtra(EXTRA_FRIENDS_IDS); mTitle = intent.getStringExtra(EXTRA_GROUP_NAME); mFriendName = intent.getStringArrayExtra(EXTRA_FRIENDS_NAMES); this.setTitle(mTitle); mMessagesLayout = (LinearLayout) this.findViewById(R.id.messages); //loadOldMessages(); addSendListener(); ImageView img = (ImageView) findViewById(R.id.backdrop); FacebookManager.fillWithUserCover(Profile.getCurrentProfile().getId(), img, getApplicationContext()); FloatingActionButton scrollDownFB = (FloatingActionButton) this.findViewById(R.id.fab); assert scrollDownFB != null; //Debug assert scrollDownFB.setOnClickListener(listener -> scrollToLast()); }
From source file:com.fullscreen.fragment.FullScreenPhotoFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View root = inflater.inflate(getTargetLayout(), container, false); setHasOptionsMenu(true);//ww w . ja va2 s.c o m Intent intent = getActivity().getIntent(); final String[] promosUrl = intent.getStringArrayExtra(BUNDLE_IMAGE_URL); mPromosSize = promosUrl.length; mMarketPackage = intent.getStringExtra(BUNDLE_MARKET_PACKAGE); mPager = (ViewPager) root.findViewById(R.id.viewPager); mIndicator = (TextView) root.findViewById(R.id.pageIndicator); mPagerAdapter = new ImagePagerAdapter(getActivity(), promosUrl); mPager.setAdapter(mPagerAdapter); setItemIndicator(0); mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { setItemIndicator(position); } @Override public void onPageScrollStateChanged(int state) { } }); return root; }
From source file:uk.org.rivernile.edinburghbustracker.android.alerts.TimeAlertService.java
/** * {@inheritDoc}//from w w w.j av a2 s .co m */ @Override protected void onHandleIntent(final Intent intent) { final String stopCode = intent.getStringExtra(ARG_STOPCODE); final String[] services = intent.getStringArrayExtra(ARG_SERVICES); final int timeTrigger = intent.getIntExtra(ARG_TIME_TRIGGER, 5); final BusParser parser = new EdinburghParser(); HashMap<String, BusStop> result; try { // Get the bus times. Only get 1 bus per service. result = parser.getBusStopData(new String[] { stopCode }, 1); } catch (BusParserException e) { // There was an error. No point continuing. Reschedule. reschedule(intent); return; } // Get the bus stop we are interested in. It should be the only one in // the HashMap anyway. final BusStop busStop = result.get(stopCode); int time; EdinburghBus edinBs; // Loop through all the bus services at this stop. for (BusService bs : busStop.getBusServices()) { // We are only interested in the next departure. Also get the time. edinBs = (EdinburghBus) bs.getFirstBus(); if (edinBs == null) { continue; } time = edinBs.getArrivalMinutes(); // Loop through all of the services we are interested in. for (String service : services) { // The service matches and meets the time criteria. if (service.equals(bs.getServiceName()) && time <= timeTrigger) { // The alert may have been cancelled by the user recently, // check it's still active to stay relevant. Cancel the // alert if we're continuing. if (!sd.isActiveTimeAlert(stopCode)) return; alertMan.removeTimeAlert(); // Create the intent that's fired when the notification is // tapped. It shows the bus times view for that stop. final Intent launchIntent = new Intent(this, DisplayStopDataActivity.class); launchIntent.setAction(DisplayStopDataActivity.ACTION_VIEW_STOP_DATA); launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); launchIntent.putExtra(DisplayStopDataActivity.ARG_STOPCODE, stopCode); launchIntent.putExtra(DisplayStopDataActivity.ARG_FORCELOAD, true); final String stopName = bsd.getNameForBusStop(stopCode); final String title = getString(R.string.timeservice_notification_title); final String summary = getResources().getQuantityString( R.plurals.timeservice_notification_summary, time == 0 ? 1 : time, service, time, stopName); // Build the notification. final NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(this); notifBuilder.setAutoCancel(true); notifBuilder.setSmallIcon(R.drawable.ic_status_bus); notifBuilder.setTicker(summary); notifBuilder.setContentTitle(title); notifBuilder.setContentText(summary); // Support for Jelly Bean notifications. notifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(summary)); notifBuilder.setContentIntent( PendingIntent.getActivity(this, 0, launchIntent, PendingIntent.FLAG_ONE_SHOT)); final Notification n = notifBuilder.build(); if (sp.getBoolean(PreferencesActivity.PREF_ALERT_SOUND, true)) n.defaults |= Notification.DEFAULT_SOUND; if (sp.getBoolean(PreferencesActivity.PREF_ALERT_VIBRATE, true)) n.defaults |= Notification.DEFAULT_VIBRATE; if (sp.getBoolean(PreferencesActivity.PREF_ALERT_LED, true)) { n.defaults |= Notification.DEFAULT_LIGHTS; n.flags |= Notification.FLAG_SHOW_LIGHTS; } // Send the notification. notifMan.notify(ALERT_ID, n); return; } } } // All the services have been looped through and the criteria didn't // match. This means a reschedule should be attempted. reschedule(intent); }
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private void handleUpdatePrevent(String action, Intent intent) { String[] packages = intent.getStringArrayExtra(PreventIntent.EXTRA_PACKAGES); boolean prevent = intent.getBooleanExtra(PreventIntent.EXTRA_PREVENT, true); Map<String, Boolean> prevents = mPreventPackages; for (String name : packages) { if (prevent) { int count = countCounter(name); prevents.put(name, count == 0); } else {/*from w w w . ja v a2 s . c om*/ prevents.remove(name); } } PreventListUtils.getInstance().save(mContext, mPreventPackages.keySet(), true); setResultCode(prevents.size()); setResultData(new JSONObject(prevents).toString()); LogUtils.logRequestInfo(action, null, prevents.size()); abortBroadcast(); }
From source file:com.piusvelte.sonet.SelectFriends.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // allow posting to multiple services if an account is defined // allow selecting which accounts to use // get existing comments, allow liking|unliking those comments setContentView(R.layout.friends);/*www.j a va 2 s . com*/ if (!getPackageName().toLowerCase().contains(PRO)) { AdView adView = new AdView(this, AdSize.BANNER, BuildConfig.GOOGLEAD_ID); ((LinearLayout) findViewById(R.id.ad)).addView(adView); adView.loadAd(new AdRequest()); } Intent intent = getIntent(); if ((intent != null) && intent.hasExtra(Accounts.SID)) { mAccountId = intent.getLongExtra(Accounts.SID, Sonet.INVALID_ACCOUNT_ID); String[] tags = intent.getStringArrayExtra(Stags); if (tags != null) { for (String tag : tags) mSelectedFriends.add(tag); } } else finish(); mHttpClient = SonetHttpClient.getThreadSafeClient(getApplicationContext()); registerForContextMenu(getListView()); setResult(RESULT_CANCELED); }
From source file:com.piusvelte.sonet.core.SelectFriends.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // allow posting to multiple services if an account is defined // allow selecting which accounts to use // get existing comments, allow liking|unliking those comments setContentView(R.layout.friends);/*from w ww .ja va2s. c om*/ if (!getPackageName().toLowerCase().contains(PRO)) { AdView adView = new AdView(this, AdSize.BANNER, SonetTokens.GOOGLE_AD_ID); ((LinearLayout) findViewById(R.id.ad)).addView(adView); adView.loadAd(new AdRequest()); } Intent intent = getIntent(); if ((intent != null) && intent.hasExtra(Accounts.SID)) { mAccountId = intent.getLongExtra(Accounts.SID, Sonet.INVALID_ACCOUNT_ID); String[] tags = intent.getStringArrayExtra(Stags); if (tags != null) { for (String tag : tags) mSelectedFriends.add(tag); } } else finish(); mHttpClient = SonetHttpClient.getThreadSafeClient(getApplicationContext()); registerForContextMenu(getListView()); setResult(RESULT_CANCELED); }
From source file:com.simas.vc.background_tasks.FFmpegService.java
@Override protected void onHandleIntent(Intent intent) { // Show notification String[] args = intent.getStringArrayExtra(ARG_EXEC_ARGS); File output = (File) intent.getSerializableExtra(ARG_OUTPUT_FILE); File progress = (File) intent.getSerializableExtra(ARG_PROGRESS_FILE); int duration = intent.getIntExtra(ARG_OUTPUT_DURATION, 0); // Launch progress notifier final ProgressNotifier notifier = new ProgressNotifier(duration, output, progress); Utils.runOnUiThread(new Runnable() { @Override//from w w w. j av a2s.c o m public void run() { // AsyncTasks should be executed on the UI thread notifier.execute(); } }); // Launch the process itself final int ffmpegResult = FFmpeg.cFFmpeg(args); // Notifier cancelling must be run on the UI thread too, so it doesn't overlap the execution Utils.runOnUiThread(new Runnable() { @Override public void run() { notifier.ffmpegCancel(ffmpegResult); } }); }
From source file:com.shafiq.myfeedle.core.SelectFriends.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // allow posting to multiple services if an account is defined // allow selecting which accounts to use // get existing comments, allow liking|unliking those comments setContentView(R.layout.friends);/* w w w. ja v a 2 s.c o m*/ if (!getPackageName().toLowerCase().contains(PRO)) { AdView adView = new AdView(this, AdSize.BANNER, MyfeedleTokens.GOOGLE_AD_ID); ((LinearLayout) findViewById(R.id.ad)).addView(adView); adView.loadAd(new AdRequest()); } Intent intent = getIntent(); if ((intent != null) && intent.hasExtra(Accounts.SID)) { mAccountId = intent.getLongExtra(Accounts.SID, Myfeedle.INVALID_ACCOUNT_ID); String[] tags = intent.getStringArrayExtra(Stags); if (tags != null) { for (String tag : tags) mSelectedFriends.add(tag); } } else finish(); mHttpClient = MyfeedleHttpClient.getThreadSafeClient(getApplicationContext()); registerForContextMenu(getListView()); setResult(RESULT_CANCELED); }
From source file:com.sharky.BillingService.java
public void handleCommand(Intent intent, int startId) { String action = intent.getAction(); if (Consts.ACTION_CONFIRM_NOTIFICATION.equals(action)) { String[] notifyIds = intent.getStringArrayExtra(Consts.NOTIFICATION_ID); confirmNotifications(startId, notifyIds); } else if (Consts.ACTION_GET_PURCHASE_INFORMATION.equals(action)) { String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID); getPurchaseInformation(startId, new String[] { notifyId }); } else if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) { String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA); String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE); purchaseStateChanged(startId, signedData, signature); } else if (Consts.ACTION_RESPONSE_CODE.equals(action)) { long requestId = intent.getLongExtra(Consts.INAPP_REQUEST_ID, -1); int responseCodeIndex = intent.getIntExtra(Consts.INAPP_RESPONSE_CODE, ResponseCode.RESULT_ERROR.ordinal()); ResponseCode responseCode = ResponseCode.valueOf(responseCodeIndex); checkResponseCode(requestId, responseCode); }/*from w w w . ja v a2s .com*/ }