top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Android Activity Crashing

+3 votes

Hi, I have used the below sample code downloaded from a website and it is crashing.

Intent sendIntent = new Intent();
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type

Let me know the possible solution.

posted May 23, 2016 by Shalini

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
Best answer

Create the text message with a string

Intent sendIntent = new Intent();
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);

// Verify that the intent will resolve to an activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {

For binary Data

Intent shareIntent = new Intent();
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));

Note the following:

You can use a MIME type of "/", but this will only match activities that are able to handle generic data streams.

answer May 24, 2016 by Karthick.c
+2 votes

Hi, there are two possibilities may be
1. permissions in manifest.xml for setAction
2. type of message that you want to set
check both and try solutions for
1. use uses-permission android:name="android.permission.SEND_SMS"
and for second
2. use `sendIntent.setType("text/plan");

answer May 23, 2016 by Shivam Kumar Pandey
Similar Questions
+2 votes

I have a data collection that is associated with a list of EditText. The data is dynamically retrieved. So, how would I access EditText dynamically and associate the value from the collection.

EditText editText = (EditText) findViewById(<How to pass id dynamically?>);
editText.setText("<my value here>");
+3 votes

With the major milestone release of Android Studio, I am worried about the suggested IDE for platform development. As we can see on the web [ ], there is a sort of tutorial to set up an Eclipse Environment for AOSP development: while it does not directly involve the ADT plugin, at the same time its presence in the environment it's useful in some situations.

Is there any plan for a substitution of Eclipse as "endorsed" IDE for AOSP?

+4 votes

What is Unable to resolve target 'android-15' until the SDK is loaded? IN eclipse I am getting the error while am try to run my app. Please help me how to solve this issue.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.