Example usage for android.content Intent getSerializableExtra

List of usage examples for android.content Intent getSerializableExtra

Introduction

In this page you can find the example usage for android.content Intent getSerializableExtra.

Prototype

public Serializable getSerializableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:net.illusor.swipeplayer.services.AudioBroadcastHandler.java

@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
    case ACTION_PLAY_AUDIO: {
        AudioFile audioFile = (AudioFile) intent.getSerializableExtra(ACTION_PLAY_AUDIO);
        this.onPlayAudioFile(audioFile);
        break;//from w w w .  j a v  a  2  s .  c  om
    }
    case ACTION_PLAY_STOP: {
        this.onPlaybackStop();
        break;
    }
    case ACTION_PLAY_PAUSE: {
        this.onPlaybackPause();
        break;
    }
    case ACTION_PLAY_RESUME: {
        this.onPlaybackResume();
        break;
    }
    }
}

From source file:name.vdg.respi55.RespiStateManager.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Command cmd = (Command) intent.getSerializableExtra(EXTRA_CMD_ID);
    switch (cmd) {
    case Start://from w  ww .  jav a2  s . c om
        Log.d(TAG, "service started with start intent");
        start();
        break;
    case Stop:
        Log.d(TAG, "service started with stop intent");
        stop();
        break;
    default:
        Log.d(TAG, "service started with unkown intent command");
        break;
    }
    return Service.START_NOT_STICKY;
}

From source file:com.thesis.asa.mainui.MainSlideActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SECURITY_MODE_SELECTED && resultCode == 0) {
        SecurityMode mode = (SecurityMode) data.getSerializableExtra(Wizard.MODE);
        SharedPreferences settings = getSharedPreferences(Utilities.FIRST_RUN_PREFERENCE, 0);
        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean(IS_FIRST_RUN, false);
        editor.putInt(Utilities.SELECTED_MODE, SecurityMode.toInteger(mode));
        editor.commit();/*w ww  . j  a v  a  2s  .  c o m*/
        Toast.makeText(this, "Finished configuring ASA", Toast.LENGTH_SHORT).show();
    }
}

From source file:com.example.swipeapp.CollectionDemoActivity.java

@SuppressWarnings("unchecked")
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_collection_demo);

    Intent intent = getIntent();

    arrayList = (ArrayList<HashMap<String, Object>>) intent.getSerializableExtra("array");

    // Create an adapter that when requested, will return a fragment representing an object in
    // the collection.
    // //  w  w  w.jav  a2  s.c o  m
    // ViewPager and its adapters use support library fragments, so we must use
    // getSupportFragmentManager.
    mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());

    // Set up action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home button should show an "Up" caret, indicating that touching the
    // button will take the user one step up in the application's hierarchy.
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Set up the ViewPager, attaching the adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);

    mViewPager.setAdapter(mDemoCollectionPagerAdapter);

}

From source file:com.quarterfull.newsAndroid.services.DownloadImagesService.java

@Override
protected void onHandleIntent(Intent intent) {
    DownloadMode downloadMode = (DownloadMode) intent.getSerializableExtra(DOWNLOAD_MODE_STRING);

    DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(this);
    Notification notify = BuildNotification();

    if (downloadMode.equals(DownloadMode.FAVICONS_ONLY)) {
        List<Feed> feedList = dbConn.getListOfFeeds();
        FavIconHandler favIconHandler = new FavIconHandler(this);
        for (Feed feed : feedList) {
            favIconHandler.PreCacheFavIcon(feed);
        }//from   w w w.  j  ava  2  s  . c  o  m
    } else if (downloadMode.equals(DownloadMode.FAVICONS_AND_PICTURES)
            || downloadMode.equals(DownloadMode.PICTURES_ONLY)) {
        long lastId = intent.getLongExtra(LAST_ITEM_ID, 0);
        List<RssItem> rssItemList = dbConn.getAllItemsWithIdHigher(lastId);
        List<String> links = new ArrayList<>();
        for (RssItem rssItem : rssItemList) {
            String body = rssItem.getBody();
            links.addAll(ImageHandler.getImageLinksFromText(body));

            if (links.size() > 10000) {
                notificationManager.notify(123, GetNotificationLimitImagesReached(10000));
                break;
            }
        }
        ((LazyList) rssItemList).close();

        maxCount = links.size();

        if (maxCount > 0) {
            notificationManager.notify(NOTIFICATION_ID, notify);
        }

        linksToImages.addAll(links);

        StartNextDownloadInQueue();
    }
}

From source file:org.geometerplus.android.fbreader.network.BearerAuthenticator.java

static boolean onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
    final BearerAuthenticator ba = ourAuthenticators.get(activity);
    boolean processed = true;
    try {/*from   w  w  w.  ja  v  a2  s.co  m*/
        switch (requestCode) {
        default:
            processed = false;
            break;
        case NetworkLibraryActivity.REQUEST_ACCOUNT_PICKER:
            if (resultCode == Activity.RESULT_OK && data != null) {
                ba.myAccount = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            }
            break;
        case NetworkLibraryActivity.REQUEST_AUTHORISATION:
            if (resultCode == Activity.RESULT_OK) {
                ba.myAuthorizationConfirmed = true;
            }
            break;
        case NetworkLibraryActivity.REQUEST_WEB_AUTHORISATION_SCREEN:
            if (resultCode == Activity.RESULT_OK && data != null) {
                final CookieStore store = ZLNetworkManager.Instance().cookieStore();
                final Map<String, String> cookies = (Map<String, String>) data
                        .getSerializableExtra(NetworkLibraryActivity.COOKIES_KEY);
                if (cookies != null) {
                    for (Map.Entry<String, String> entry : cookies.entrySet()) {
                        final BasicClientCookie2 c = new BasicClientCookie2(entry.getKey(), entry.getValue());
                        c.setDomain(data.getData().getHost());
                        c.setPath("/");
                        final Calendar expire = Calendar.getInstance();
                        expire.add(Calendar.YEAR, 1);
                        c.setExpiryDate(expire.getTime());
                        c.setSecure(true);
                        c.setDiscard(false);
                        store.addCookie(c);
                    }
                }
            }
            break;
        }
    } finally {
        if (processed) {
            synchronized (ba) {
                ba.notifyAll();
            }
        }
        return processed;
    }
}

From source file:com.firesoft.member.Activity.F0_ProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.c0_member_update);

    Intent intent = getIntent();
    member = (SIMPLE_MEMBER) intent.getSerializableExtra("member");
    init(member);/*from  w w  w .j a  va  2  s.co  m*/
    mShared = getSharedPreferences(MemberAppConst.USERINFO, 0);
    mAlertView = new AlertView("???", "??", "?",
            new String[] { "" }, null, this, AlertView.Style.Alert, this).setCancelable(true)
                    .setOnDismissListener(this);

    mMemberModel = new MemberModel(this);
    mMemberModel.addResponseListener(this);

    EventBus.getDefault().register(this);
}

From source file:com.jbirdvegas.mgerrit.ProjectsList.java

public void onEventMainThread(StartingRequest ev) {
    Intent intent = ev.getIntent();
    if (intent.getSerializableExtra(GerritService.DATA_TYPE_KEY) == GerritService.DataType.Project) {
        mSwipeLayout.setRefreshing(true);
    }//from  w w  w. j av  a2 s .c o  m
}

From source file:com.jbirdvegas.mgerrit.ProjectsList.java

public void onEventMainThread(ErrorDuringConnection ev) {
    Intent intent = ev.getIntent();
    if (intent.getSerializableExtra(GerritService.DATA_TYPE_KEY) == GerritService.DataType.Project) {
        mSwipeLayout.setRefreshing(false);
    }//ww  w.j  ava2s.com
}

From source file:net.forkk.autocron.EditAutomationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    assert intent != null;
    mAutomationPointer = (ComponentPointer) intent.getSerializableExtra(EXTRA_AUTOMATION_POINTER);

    mShowTriggerList = mAutomationPointer instanceof Event.Pointer;

    setContentView(R.layout.activity_edit_automation);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    assert actionBar != null;
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from   ww  w  .jav  a  2  s .c  o  m*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar.addTab(actionBar.newTab().setText(mPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}