List of usage examples for android.content Intent getSerializableExtra
public Serializable getSerializableExtra(String name)
From source file:com.gcssloop.diycode.activity.UserActivity.java
private void initUserInfo(ViewHolder holder) { Intent intent = getIntent(); User user = (User) intent.getSerializableExtra(USER); if (null != user) { setTitle(user.getLogin());/*from w w w . j a va 2s . c o m*/ holder.setText(user.getName(), R.id.username); holder.loadImage(this, user.getAvatar_url(), R.id.avatar); mDiycode.getUser(user.getLogin()); } else { } }
From source file:br.ufrn.dimap.pubshare.download.service.DownloaderService.java
/** * The IntentService calls this method from the default worker thread with * the intent that started the service. When this method returns, IntentService * stops the service, as appropriate./*w ww. ja v a2s . c om*/ */ @Override protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent on DownloadService"); Article selectedArticle = (Article) intent.getSerializableExtra(Article.KEY_INSTANCE); if (!AndroidUtils.isExternalStorageAvailable()) { // Generate Menssages NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_menu_notifications) .setContentTitle(getResources().getString(R.string.external_storage_unavailable)) .setContentText(getResources().getString(R.string.check_media_availability)); Notification notification = mBuilder.build(); // Set the Notification as ongoing notification.flags = notification.flags | Notification.FLAG_AUTO_CANCEL; NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nManager.notify(0, notification); return; } DownloadManager dowloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); // since API level 9 Request request = new Request(Uri.parse(selectedArticle.getRemoteLocation())); request.setAllowedNetworkTypes(Request.NETWORK_WIFI | Request.NETWORK_MOBILE); request.setTitle(selectedArticle.getTitle()); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, selectedArticle.generateFileName()); request.setVisibleInDownloadsUi(true); long enqueue = dowloadManager.enqueue(request); Log.d(TAG, "Download enqueue..." + enqueue); ArticleDownloaded articleDownloaded = new ArticleDownloaded(); articleDownloaded.setDownloadKey(enqueue); DownloadDao downloadDao = new DownloadDao(this); downloadDao.insert(articleDownloaded); Log.d(TAG, "Insert " + articleDownloaded + " in SqLite: OK"); }
From source file:behsaman.storytellerandroid.TextviewerSlideActivity.java
private void setupPager() { Intent intent = getIntent(); this.pieces = (ArrayList<Object>) intent.getSerializableExtra(StoryPageActivity.STORY_PIECES_KEY); this.storyModel = (StoryModel) intent.getSerializableExtra(StoryPageActivity.STORY_MODEL_KEY); Integer selected_page = (Integer) intent.getSerializableExtra(StoryPageActivity.STORY_SELECTED_PIECE_KEY); // Instantiate a ViewPager and a PagerAdapter. mPager = (ViewPager) findViewById(R.id.pager); mPager.setPageTransformer(true, new ZoomOutPageTransformer()); mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager(), this.pieces, storyModel, this); mPager.setAdapter(mPagerAdapter);/*from w w w . j ava 2s . c o m*/ mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When changing pages, reset the action bar actions since they are dependent // on which page is currently active. An alternative approach is to have each // fragment expose actions itself (rather than the activity exposing actions), // but for simplicity, the activity provides the actions in this sample. invalidateOptionsMenu(); } }); //Set page navigation if (selected_page != null) mPager.setCurrentItem(selected_page); }
From source file:com.liferay.alerts.receiver.WearableVoteReceiver.java
@Override public void onReceive(Context context, Intent intent) { long alertId = intent.getLongExtra(EXTRA_ALERT_ID, 0); PollsQuestion question = (PollsQuestion) intent.getSerializableExtra(EXTRA_QUESTION); int questionId = question.getQuestionId(); Bundle input = RemoteInput.getResultsFromIntent(intent); String description = input.getCharSequence(EXTRA_CHOICE).toString(); List<PollsChoice> choices = question.getChoices(); int choiceId = getChoiceId(choices, description); VoteCallback callback = new VoteCallback(context, alertId, questionId); callback.vote(choiceId);/* w ww .j av a 2s . com*/ }
From source file:com.chatwing.whitelabel.services.UpdateGcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { String action = intent.getAction(); if (action == null) return;/* ww w.ja va 2 s . c o m*/ User user = (User) intent.getSerializableExtra(EXTRA_USER); if (user == null) { user = mUserManager.getCurrentUser(); } if (action.equals(ApiManager.GCM_ACTION_ADD)) { addGcmRegistrationIdToBackend(user); } else if (action.equals(ApiManager.GCM_ACTION_REMOVE)) { removeGcmRegistrationIdFromBackend(user); } }
From source file:com.cpd.activities.NewsOpenActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_news_open); if (getResources().getBoolean(R.bool.portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else {/* w w w.ja va 2s . c o m*/ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } Intent intent = getIntent(); mNewsVo = (NewsVo) intent.getSerializableExtra(AppTags.NEWS_VO); TrackerUtils.clickNewsArticle(mNewsVo.title); final TextView articleTextView = (TextView) findViewById(R.id.news_activity_text); mLoader = new NewsLoader(new NewsParser.NewsReady() { @Override public void OnNewsReady(NewsVo newsArticle) { mConnectionTries++; /* Avoid infinite loop */ if (mConnectionTries <= ConnectionUtils.MAX_NETWORK_TENTATIVES) { if (newsArticle.articleText == null) { mLoader.run(mNewsVo, true); } else { // Interpret HTML tags mConnectionTries = 0; articleTextView.setText(Html.fromHtml(newsArticle.articleText)); articleTextView.setMovementMethod(LinkMovementMethod.getInstance()); if (DebugUtils.DEBUG) Log.d(TAG, "Opened article: " + newsArticle.title); } } else { if (DebugUtils.ERROR) Log.e(TAG, "Not connecting to news!"); } } }); mLoader.run(mNewsVo, true); // The RssParser already gives the title and image. Therefore, we can load this content // while the NewsParser is running. Toolbar toolbar = (Toolbar) findViewById(R.id.news_open_toolbar); setSupportActionBar(toolbar); ImageView imageView = (ImageView) findViewById(R.id.news_activity_picture); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openImageActivity(); } }); Picasso.with(this).load(mNewsVo.imgLargeUrl).into(imageView); TextView titleView = (TextView) findViewById(R.id.news_activity_title); titleView.setText(mNewsVo.title); }
From source file:com.ymotongpoo.android.gopher.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load user information for navigation header mSharedPref = getSharedPreferences(User.USER_PREF, Context.MODE_PRIVATE); Intent intent = getIntent(); if (intent != null) { mUser = (User) intent.getSerializableExtra(User.USER_KEY); } else {//from www. j ava 2 s . c o m String username = mSharedPref.getString(getString(R.string.pref_username_key), getString(R.string.nav_header_username)); String email = mSharedPref.getString(getString(R.string.pref_email_key), getString(R.string.nav_header_email)); mUser = new User(username, email, ""); } setContentView(R.layout.activity_main); // Load main content fragment if (savedInstanceState == null) { ACUnitFragment acUnitFragment = new ACUnitFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment_container, acUnitFragment); ft.commit(); } // Create toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); // There is a bug in Design Support Library 23.1.0 and the workaround is added in 23.1.1. // http://goo.gl/WHwfeB View navHeaderView = navigationView.getHeaderView(0); TextView usernameTextView = (TextView) navHeaderView.findViewById(R.id.nav_header_username); usernameTextView.setText(mUser.getUsername()); TextView emailTextView = (TextView) navHeaderView.findViewById(R.id.nav_header_email); emailTextView.setText(mUser.getPassword()); }
From source file:com.acrylicgoat.bcponline.fragments.CPListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //get category Intent intent = getActivity().getIntent(); Category category = (Category) intent.getSerializableExtra(getString(R.string.category)); contentList = getCategory(category.getName()); if (savedInstanceState != null) { curPosition = savedInstanceState.getInt(getString(R.string.list_position)); }// w ww . ja v a 2 s. c o m }
From source file:info.martinmarinov.dvbservice.DvbService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { final DeviceFilter deviceFilter = (DeviceFilter) intent.getSerializableExtra(DEVICE_FILTER); // Kill existing connection if (worker != null && worker.isAlive()) { worker.interrupt();//from w ww. j a v a 2 s . c om try { worker.join(15_000L); } catch (InterruptedException ignored) { } if (worker != null && worker.isAlive()) { throw new RuntimeException("Cannot stop existing service"); } } worker = new Thread() { @Override public void run() { DvbServer dvbServer = null; try { dvbServer = new DvbServer(getDeviceFromFilter(deviceFilter)); DvbServerPorts dvbServerPorts = dvbServer.bind(InetAddressTools.getLocalLoopback()); dvbServer.open(); // Device was opened! Tell client it's time to connect broadcastStatus(new StatusMessage(null, dvbServerPorts, deviceFilter)); startForeground(); dvbServer.serve(); } catch (Exception e) { e.printStackTrace(); broadcastStatus(new StatusMessage(e, null, deviceFilter)); } finally { if (dvbServer != null) dvbServer.close(); } Log.d(TAG, "Finished"); worker = null; stopSelf(); } }; worker.start(); return START_NOT_STICKY; }
From source file:com.keylesspalace.tusky.AccountListActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_account_list); Type type;//from w w w . ja v a 2s .c o m Intent intent = getIntent(); if (intent != null) { type = (Type) intent.getSerializableExtra("type"); } else { type = Type.BLOCKS; } Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar bar = getSupportActionBar(); if (bar != null) { switch (type) { case BLOCKS: { bar.setTitle(getString(R.string.title_blocks)); break; } case MUTES: { bar.setTitle(getString(R.string.title_mutes)); break; } case FOLLOW_REQUESTS: { bar.setTitle(getString(R.string.title_follow_requests)); break; } case FOLLOWERS: bar.setTitle(getString(R.string.title_followers)); break; case FOLLOWING: bar.setTitle(getString(R.string.title_follows)); } bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayShowHomeEnabled(true); } FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); AccountListFragment fragment; switch (type) { default: case BLOCKS: { fragment = AccountListFragment.newInstance(AccountListFragment.Type.BLOCKS); break; } case MUTES: { fragment = AccountListFragment.newInstance(AccountListFragment.Type.MUTES); break; } case FOLLOWERS: { String argument = intent.getStringExtra(ARG_EXTRA); fragment = AccountListFragment.newInstance(AccountListFragment.Type.FOLLOWERS, argument); break; } case FOLLOWING: { String argument = intent.getStringExtra(ARG_EXTRA); fragment = AccountListFragment.newInstance(AccountListFragment.Type.FOLLOWS, argument); break; } case FOLLOW_REQUESTS: { fragment = AccountListFragment.newInstance(AccountListFragment.Type.FOLLOW_REQUESTS); break; } } fragmentTransaction.replace(R.id.fragment_container, fragment); fragmentTransaction.commit(); }