Android posting to Twitter - java

I have seen that there are a few good libraries out there. These seem to come with all the bells and whistles.
My application only needs to post a status update to a twitter account. Each time the user would have to enter their details. This is not the major part of my app, so I was wondering if there are any condensed libraries or simpler ways to achieve this without including all of the features that come with larger libraries.
Any advice greatly appreciated.

You can use the ACTION_SEND intent. Any application capable of sharing, including a twitter and facebook apps if installed, listens for that intent. The system will then show a dialog to let the user choose how they want to share the message. Use something like the following code:
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, getString(R.string.share)));

Related

How to send a SharedPreference from an App to another?

Hey I have an app(Let's call it app A) on the playstore and I want to replace it with another completely different app(Let's call it app B) but I need some of the SharedPreference in app A to be sent to app B but I don't know how to send data from an app to another does anyone know how or if it's even possible. I tried creating a file containing the data on the sdcard but I don't like that idea since it is not secure, so if you anyone has a better idea please help me.
I think best variant for you would be sending an intent with all preferences you want to store from the first app. In second app you need to register intent receiver that will get all data from intent and store it in preferences. Here is an article that described this approach more detailed.

Open Another App with android.intent.action.VIEW

I want to open another app and open a specific page in it!
in their guide they said to use the bellow for default action
android.intent.action.VIEW
and use a kind of intent, which didn't get which, like bellow to go to that specific page:
somecompany://details?id=com.example.calendar
but i don't know how!
And i tryed a ton of solutions but coudn't do it !
Thanks for your help.
I think this is what you're asking for. This will open a specific app's page in the Google Play store.
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(
"market://details?id=com.mycompany.mypackage")));
Don't replace the word market. That is specifically reserved by Android to open the Google Play store.
You can launch an app using intents. But to go to a specific page in the app, there should be a pre defined intent to reach there. Either it can be custom intent defined by that app and exposed to others or may be predefined system app. For example, you can open Settings application and reach a particular page in it based on the intents "Setting Application" has defined. Another example is "Camera Application". You can launch it and reach some page in it but not all pages.
In your case you may try something like this though:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "video/mp4");
I hope you understand what I meant.

Opening pdf from activity

I am developing an app which has one activity that contains a lot of text (really a lot). I thought it would be the best solution to make a PDF with the information in it and open that file right from the app. So when people open the activity, the PDF is opened in a PDF capable viewer installed.
Do you guys know how I have to work this out, because I think I will need to use an Intent, but which one? And how to direct open the viewer?
Thanks for all the help or any energy you put in this question in advance.
Do you guys know how I have to work this out, because I think I will need to use an Intent, but which one?
Use this:
Intent i=new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(pathToYourPdfFile), "application/pdf");
startActivity(i);

How Can I Communicate with another application?

I'd like ask you if there's a way to send information or commands to other applications.
For example: a person is typing a message to one, and after ten seconds my program adds (by using the command append("text").to(EditText); ) a string like "hello" in the EditText of the message.
I discovered that information can be shared between different apps through ContentProviders
Is there a way to accomplish this?
This is only possible when the developer of this particular app predicted such behavior. It could be done simply by broadcasting intents between apps, but this "another" app must have a suitable Broadcast Receiver to make a use of this intents. http://developer.android.com/guide/components/intents-filters.html
Or, you can fire up an intent on another app and bundle your Data into it and pass it through Intent object. Check out this link. I purposely haven't written a code. I think everyone should learn on their own. Remember,The developer site is the Bible for Android.

Launching system and third party apps in android

I have searched ALOT now, i cant find a solid way to run apps like calendar, camera, facebook, twitter, insatgram, and all kinds of apps in android. I know that i need to use intents, but HOW can i do it? I really need help! Please help me and thanks alot!
There is no such concept in Android as "run apps". You start activities. Talented developers do not focus on specific apps (e.g., "facebook, twitter, insatgram"), because those apps may not exist on any given device. Instead, you focus on generic capabilities (e.g., use an ACTION_SEND Intent with startActivity() to share something, create a launcher by using PackageManager to find those activities that support ACTION_MAIN and CATEGORY_HOME).
If you want to launch some other application from your android application then you should know the package name for that particular application For example for launching facebook use
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);
Otherwise this can also be used
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
If you want to launch the default android applications installed for some particular kind of operation then you can use implicit intents for that. For example to start a browser you can use
Uri webpage = Uri.parse("http://www.android.com");
Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);
startActivity(intent);
You should take also take a look at intents and intent filters and how to allow other apps to open your application.

Categories