Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1055413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:33:31+00:00 2026-05-16T17:33:31+00:00

Currently I’m trying to implement a reusable Twitter status ‘poster’. The Twitter status part

  • 0

Currently I’m trying to implement a reusable Twitter status ‘poster’. The Twitter status part of it is working, but the reusable bit isn’t. Here’s what I’m doing:

An activity called SummaryDisplay imports a class TweetStatus and calls a function sendStatus. It also implements a listener which is called when TweetStatus can confirm that the status was successfully sent. So far so good.

TweetStatus sends an intent to another activity, OAUTH, which will return with the user token and secret allowing us to ‘login’ to Twitter.

If OAUTH can’t find any saved tokens and secrets, it sends an intent to the browser so the user can login to Twitter and confirm that our app is allowed to send tweets on their behalf. Twitter than uses a callback to return to the OAUTH application (by using an intent filter within the manifest we make our own android:scheme and host):

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="my-app" android:host="twitter-login-success" />
 </intent-filter>

The callback URI is then:

private static final Uri CALLBACK_URI = Uri.parse("my-app://twitter-login-success");

It is because of this callback being an intent that the OAUTH class has to extend activity (so it can receive these intents).

So the problem is in OAUTH returning with the token and secret (shown in bold above). Currently OAUTH sends an intent to SummaryDisplay that then sends the data to TweetStatus. The problem is that the SummaryDisplay intent is hardcoded:

Intent i = new Intent(this, SummaryDisplay.class);

so the OAUTH class is no longer reusable as a new one will need to be made for each activity which wants to send a Twitter status.

One option is for the callback from Twitter to be changed to SummaryDisplay instead of OAUTH, but then this requires changing the callback to one of your choice (one not registered with Twitter and I need to check if that’s allowed). Another option which I’m trying is to use StartActivityForResult.

So:

TweetStatus calls OAUTH with StartActivityForResult,

OAUTH calls the browser,

Browser then calls OAUTH back using a callback URI,

OAUTH returns result to whomever started it.

Therefore reusable. However the callback URI received from the browser is seemingly creating a new instance of OAUTH which has no idea who to callback, so just does nothing. I’ve tried setting the android:launchMode to singleInstance but this disables the result from being sent (with LogCat reporting):

09-08 10:22:00.742: WARN/ActivityManager(563): Activity is launching as a new task, so cancelling activity result.

Are there any other ways of doing this? Is there, for example, a way of sending a “class” of yourself in an intent which can then be used in

Intent i = new Intent(this, myClassVariableSetUsingAnIntent);

So I can then use

android:launchMode="singleInstance"

Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:33:32+00:00Added an answer on May 16, 2026 at 5:33 pm

    Is there, for example, a way of sending a “class” of yourself in an intent…

    You could use createPendingResult() to pass an object in an Intent extra that can be used later to trigger onActivityResult(). Or, you can do a private “broadcast”, specifying an action and package to restrict the scope to only go back to the originating app. Here is a sample client and remote service that demonstrate the use of these two — in your case, you wouldn’t be using them from a service, of course, but it’s the only sample code I have handy. One of these should, in principle, let you get your data back to the original activity. From there, it is a matter of finish()-ing everything between where you are and that activity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I am writing up a bit of a product-based CMS as my first
Currently I know of only two ways to cache data (I use PHP but
Currently my AJAX is working like this: index.php <a href='one.php' class='ajax'>One</a> <div id=workspace>workspace</div> one.php
Currently I'm storing the settings for my custom addins in the registry but this
Currently for sending rails emails we use google apps for our emails, but we're
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
Currently my workflow with Emacs when I am coding in C or C++ involves
Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
Currently I'm doing some unit tests which are executed from bash. Unit tests are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.