Tag: android-intent

How do I sendBroadcast(intent) from myDialog and receive in myActivity?

So, I’m trying to get a handle on BroadcastReceivers and Intent filters. I have a custom Dialog that I create in MyActivity. In the Dialog, I have a Button. When the button gets clicked, I want to send a broadcast that MyActivity’s receiver will pick up. Here’s what I have right now: //MyActivity.java class myActivity […]

Android Multiple Notification

I have developing an App where the user can create event and set notification for that very event. So I want to add multiple notification. I am using the following code. final Notification notifyDetails = new Notification(R.drawable.icon, “Myapp”,calendar.getTimeInMillis()); Context context = getApplicationContext(); Intent notifyIntent = new Intent(context, ViewDoughnut.class); PendingIntent pendingIntent = PendingIntent.getActivity(ViewCal.this, 0, notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK); […]

What is the best way for pick a video in Android

I got a perfect Intent.ACTION_PICK with my picture. startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), SELECT_IMAGE); But it doesn’t work with video. When i click on a video of my list, it play the vidoe instead of send me back. startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.INTERNAL_CONTENT_URI), SELECT_VIDEO); An idea ?

Android Search widget – difference between onQueryTextSubmit and sending Intent to SearchableActivity?

I have an activity that contains a SearchView widget. I am handling the results of the text search using an onQueryTextSubmit listener, and this works fine. (The activity itself is designated as a Searchable Activity). I recently decided to add voice recognition, by adding the “voiceSearchMode” attribute in the searchable.xml file: searchable.xml <?xml version=”1.0″ encoding=”utf-8″?> […]

Android: passing parameters between classes

I have a class2 which is involved by class1 when clicks are made. I have to pass some parameters/objects from class1 to class2. I only know the standard way which does not have an option of passing parameters. // launch the full article Intent i = new Intent(this, Class2.class); startActivity(i);

In Android: How to Call Function of Activity from a Service?

I have an Activity (A) and a Service (S) which gets started by A like this: Intent i = new Intent(); i.putExtra(“updateInterval”, 10); i.setClassName(“com.blah”, “com.blah.S”); startService(i); A have a function like this one in A: public void someInfoArrived(Info i){…} Now I want to call A.someInfoArrived(i) from within S. Intent.putExtra has no version where I could […]

GMail for KitKat crashes on sending attachments that are not images or videos

UPDATE 3: Seems like all this was caused by the OTA upgrade to KitKat 4.4. Force stopping and clearing data of the GMail app fixed the issue. Not really a user-friendly result of an OTA update. UPDATE 2: The crash is purely due to the new Gmail file handling in Android 4.4 KitKat. When adding […]

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.ViewGroup.getPaddingLeft()' on a null object reference

I’m trying to use an Intent to start an Activity, but the mentioned error occurs on second activity’s setContentView(); Here are my code and the layout file. itemactivity.xml: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”match_parent” android:layout_width=”match_parent” android:orientation=”vertical”> </LinearLayout> MainActivity: Intent i=new Intent(MainActivity.this,ItemActivity.class); startActivity(i); ItemActivity: @Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.itemactivity); // this is where error […]

From Notification: AlertDialog without UI

I’m creating a notification which fires an Intent. Here a really shortened excerpt of my code… Notification notification = new Notification(R.drawable.icon, “notification”, System.currentTimeMillis()); NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(BackgroundService.this, ConnectionHandler.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.addFlags(Intent.FLAG_FROM_BACKGROUND); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, getString(R.string.notification_title), getString(R.string.notification_body), pendingIntent); notification.flags |= notification.FLAG_AUTO_CANCEL; nm.notify(1, notification); In my intent (ConnectionHandler.class), […]

Sending an email with attachments programmatically on Android

I wish to implement a button that upon pressing it will open the default email client with an attachment file. I am following this, but am getting an error message on the startActivity, saying it is expecting an activity param while I am giving it an intent. I am using API 21 and Android Studio […]

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