Tag: android-intent

How to capture the new Intent in onNewIntent()?

I want to pass a new, but different, Intent to an Activity. How do you differentiate between the new Intent and previous Intents? What kind of code goes into onNewIntent()? An example will be very helpful.

onActivityResult For Fragment

I currently have a base activity which is hosting a single fragment. Inside the fragment I have a method which starts the contact chooser. private void chooseContacts() { Intent pickContactIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST); } When this activity returns how should I capture the results. I have tried adding a @Override public […]

Android – Opening the email application?

I want to open the email application on my android app: The following code crashes Am I doing anything wrong? please provide code Intent i = new Intent (Intent.ACTION_SEND,Uri.fromParts(“mailto”, “testemail@gmail.com”, null)); this.startActivity(i);

Android Overriding onBackPressed()

Is it possible to override onBackPressed() for only one activity ? On back button click I want to call a dialog on a specific Activity, but in all other activities i want it to work as it worked before (going to previous activities) . . . Thanks For your anwsers in advance. EDITED Thank you […]

Why the PendingIntent doesn't send back my custom Extras setup for the Intent?

This questions somehow relates to the question when I was looking to get the extras back in startActivityForResult but now I face another challenge. I have subscribed to receive ProximityAlerts and I have explicitly constructed the Intent to include some Extras. But when I got the service the extras are not there. After the answers […]

Testing that button starts an Activity with Robolectric

Hi I have the following code: @RunWith(Test9Runner.class) public class MainActivityTest { private MainActivity activity; private Button pressMeButton; @Before public void setUp() throws Exception { activity = new MainActivity(); activity.onCreate(null); pressMeButton = (Button) activity.findViewById(R.id.button1); } @Test public void shouldUpdateResultsWhenButtonIsClicked() throws Exception { pressMeButton.performClick(); ShadowActivity shadowActivity = shadowOf(activity); Intent intent = shadowActivity.getResultIntent(); System.out.print(intent.toString()); } } But I […]

How to find Intent source in Android?

Possible Duplicate: Android: How to get the sender of an Intent? Is there a way in android to find the source activity which fires a INTENT (in the destination activity)? The scenario is I have two activities A and B. Both fire an intent to call activity C. Activity C displays extra information based on […]

How to capture an image and store it with the native Android Camera

I am having a problem capturing an image and storing it from the native camera app. Here is a sample of some of my code. _path = Environment.getExternalStorageDirectory() + “make_machine_example.jpg”; File file = new File( _path ); Uri outputFileUri = Uri.fromFile( file ); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE ); intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri ); startActivityForResult( intent, […]

Memory leaks with custom font for set custom font

The following code for setting custom fonts slows down my whole app. how do i modify it to avoid memory leaks and increase the speed and manage memory well? public class FontTextView extends TextView { private static final String TAG = “FontTextView”; public FontTextView(Context context) { super(context); } public FontTextView(Context context, AttributeSet attrs) { super(context, […]

Android Intent Cannot resolve constructor

I have a first class extending Fragment, and a second class extending Activity. My Fragment is working fine, and my code for the Intent in the Fragment is : ImageButton button= (ImageButton) getView().findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(MyFragment.this, MyClass.class); MyFragment.this.startActivity(myIntent); } }); My class MyClass code […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.