If you know to which activity you want to go in onBackPressed() you can start the activity with the FLAG_ACTIVITY_CLEAR_TOP. It would switch to the instance of MenuActivity if an instance is existing, but it would also remove all activity instances which are between your current activity instance and the...

You are being prompted for entering the pin because that is what you are requesting in your pairingIntent. Instead of using pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN); pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, 1234); Use pairingIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, PAIRING_VARIANT_PASSKEY_CONFIRMATION); As mentioned here, The user will be prompted to confirm the passkey displayed on the screen or an app will confirm the...

This occur when user clicks URL in text In this case, the URL is malformed: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=href (has extras) } The URL is href. That is not a valid URL. Here is the part where I do TextView html settings: That...

the chooser target intent is not the PendingIntent. For instance, in the following snippet, I am declaring intent for ACTION_SEND, with type text/plain, and this is the my target intent for the Intent.createChooser. Then I am creating another Intent, receiver, and a handler, the PendingIntet, which will invoke onReceive of...

tv8=(TextView)findViewById(R.id.editText4); tv9=(TextView)findViewById(R.id.editText5); tv10=(TextView)findViewById(R.id.editText6); Change these to: tv8=(TextView)findViewById(R.id.textView4); tv9=(TextView)findViewById(R.id.textView5); tv10=(TextView)findViewById(R.id.textView6); You just used the wrong id's....

because in your code, Intent intent = new Intent(this, GetLRL.this); // <<- Here this refers to View.OnClickListener not an Activity reference From above code line, this refers to onClickListener and Intent Requires Application Context as First argument and use .class as Second Argument. So change your code line like, Intent...

Technically this flag is required. But since it is required, Android is nice and will just set it for you ;-) The reason it is required is as follows: The code that processes the Notification and calls startActivity() to actually launch the Intent, isn't running in a "task". It is...

I managed to get it working properly without the duplicates by having our background service call a custom activity: public static void installDownloadedApplication(Context context) { Intent intent = new Intent(context, InstallActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } Then our custom activity does what the background service used to do: /** * We use...

You can pass parameter with Intent like this notificationIntent.putExtra("fragment", 1); Where 1 is your fragment index and inside your HomeActivity you can use this int id=getIntent().getIntExtra("fragment", 0); viewPager.setCurrentItem(id); ...

Below code is working for me to get content URI on latest Google Photos as well. What i have tried is writing to temp file and return temp image URI, if it has authority in content URI. You can try same: public static String getImageUrlWithAuthority(Context context, Uri uri) { InputStream...

There are two approaches to do. the common one use startActivityForResult in your calling activity to start the activity. Here I use ActivityCompat for backward compatibility. ActivityCompat.startActivityForResult(this, new Intent(this, MyActivity.class), 0, null); Then in the callee activity, you can use the following code to detect the calling activity. if (getCallingActivity()...

View row=null; Is defined twice as local variable in if{} block, and as class field in adapter. Row variable here: TextView titulo=(TextView) row.findViewById(R.id.textView1); ImageView icone=(ImageView) row.findViewById(R.id.imageView1); is declared as adapter field, assigned to null (probably to avoid compiler complains) and then never touched again. Solution - just declare variable in...

From Storage Options | Android Developers: By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). ACTION_CROP launches an "other application" that supports cropping, and passes it the URI of the file to crop. If that file...

In order for this check to work, you need to be absolutely sure that the PendingIntent only exists when the alarm is set. There are 2 things you can do to ensure that is so: 1) When testing your code, make sure that you uninstall your application and then reinstall...

Check out the "Setting up a regular activity PendingIntent" section of the android notifications. You are not following the guidelines laid out in the example. Particularly, you don't do the following: Create a back stack based on the Intent that starts the Activity: Create the Intent to start the Activity....

if you ever bothered to read what AsyncTask has of methods you would have noticed that AsyncTask class has a method called cancel which accepts boolean value. public final boolean cancel (boolean mayInterruptIfRunning); Attempts to cancel execution of this task. This attempt will fail if the task has already completed,...

There is no action with the name android.intent.action.SETTINGS. Try to remove the <intent-filter> from your manifest and add this code snippet in the onClick() method: Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); Take a look at this SO question Opening Android Settings programmatically...

that can be downloaded and installed into the device silently That is not possible, except perhaps on a rooted device or via a special system app. Otherwise, the user will be involved in the installation of your plugins. Can I create an apk that when installed is not visible...

There are many ways to handle this, here is one that (I believe) is quite simple to implement. Since your A app [presumably] knows what it is installing: App A: Add a BroadcastReceiver to react to the installation, though by default it is off. Android: BroadcastReceiver on application install /...

First, do not use Class.forName(). Either use if or a Class[] and just reference the Accelerometer.class and MultiTouch.class objects. Second, your manifest has: <activtiy android:name=".Accelerometer" android:label="Accelerometer" /> which has the element name spelled incorrectly. Try: <activity android:name=".Accelerometer" android:label="Accelerometer" /> ...

Seems like these two approaches are very different: The start...forResult(...) methods start an intent or sub-activity in a way that allows for a result to be returned to the activity that executed the start...forResult(...). The result will be passed back to the activity's onActivityResult(...) method. All other ways of launching...

You need to pass to Intent constructor an instance of Context class. So if you need to start new activity from Fragment you shall write new Intent(getActivity(), NextActivity.class); and start it like getActivity().startActivity(myIntent);

Source: Getting a Result from an Activity From Activity1: public static final String RESULT_REQUEST = 1; When you want to start Activity2: Intent intent = new Intent(this, Activity2.class); startActivityForResult(intent, RESULT_REQUEST); This will be called when Activity2 is finished: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check...

You have a problem with the Context used for your Intent, change from: Intent intent = new Intent(this, mWC[position].activityClass); to Intent intent = new Intent(getActivity(), mWC[position].activityClass); or Intent intent = new Intent(view.getContext(), mWC[position].activityClass); ...

It's possible to create a mock tag object instance using reflection (note that this is not part of the public Android SDK, so it might fail for future Android versions). Get the createMockTag() method though reflection: Class tagClass = Tag.class; Method createMockTagMethod = tagClass.getMethod("createMockTag", byte[].class, int[].class, Bundle[].class); Define some constants...

Take a look at the selected as best answer here Take photo w/ camera intent and display in imageView or textView? and you could find out how to take a picture and set it as a background of an imageView programmatically

Your code transaction.replace(R.id.detail_container...Now this may be the correct UI element. I am assuming this is the correct UI. If so, fragment_wc_bank layout xml does not have that ID detail_container, hence you get error, simple as that. However activity_main.xml has that ID, again I am assuming detail_container is the correct UI...

What I want is that I need the reference to the current Activity of ANY application that is on the foreground. That is not possible. Other applications are running in other processes; you do not have access to Java objects, such as Activity instances, in those processes....

I don't want to start a Service, or Activity, or broadcast anything... Then you cannot use ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(). Is there just a simple way to create this PendingIntent to execute just a block of code? No. The conventional use case for this API is to find out about changes in...

When you use FLAG_ACTIVITY_SINGLE_TOP, you can retrieve the Intent in the onNewIntent() method, not in onCreate(). @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String TOKEN_VALUE = intent.getStringExtra("TOKEN_VALUE"); String params = intent.getStringExtra("params"); // and so on .... } For singleTop Activities, the onNewIntent() method acts as an entry point which is...

I don't understand fully what's the purpose of your code, or the semantics of the variables, but I believe you want to set the default value to 0 on your getIntExtras Integer hasilNormal1 = hasilIntent.getIntExtra("hasilBNormal1", 0); Integer hasilNormal2 = hasilIntent.getIntExtra("hasilBNormal2", 0); ... Also, it seems that you are losing the...

The Number class implements Serializable. So you should be able to do the following: Bundle extras = getIntent().getExtras(); Number[] series1Numbers = (Number[]) extras.getSerializable("plotpoints"); ...

This is how I was able to set alarm from my activity to ALARM app of Android. With AlarmManager its not possibe it seems. Thank you guys for your answers. Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); l = getIntent().getExtras().getString("song"); i.putExtra(AlarmClock.EXTRA_HOUR, pickerTime.getCurrentHour()); i.putExtra(AlarmClock.EXTRA_MINUTES, pickerTime.getCurrentMinute()); i.putExtra(AlarmClock.EXTRA_RINGTONE, l); ...

You have declared your PhonecallReceiver as abstract. This means that Android cannot instantiate it when it needs to. You need to rethink your architecture. BroadcastReceivers declared in the manifest cannot be abstract because Android needs to be able to instantiate them itself as needed. Either make your PhonecallReceiver concrete (not...

Your Intent is used to explicitly start the AlarmReceiver class which is a BroadcastReceiver. Hence, you need to use getBroadcast(), not getService(), to create the PendingIntent object. Replace PendingIntent pIntent = PendingIntent.getService(this, 0, intent, 0); with PendingIntent pIntent = PendingIntent.getBroadcast(this, 0, intent, 0); Try this. This will work. ...

The ActionBar back is really the "Up" button. The distinction between it and the device back button is that the "Up" button is meant to go up in the screen hierarchy (back to an instance of the parent activity) while the device back button is meant to go back chronologically...

Suppose you just need to call finish(), like this: findViewById(R.id.btnCancelar).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); The reason for the NullPointerException maybe is that the layout id of R.id.content_frame could not be found in the AddEscolas activity. If you need to update the EscolasFragment fragment...

Make sure that WCBankActivity extends Activity class and FragmentWCBank Fragment. It looks to me that WCBankActivity isn't Activity for some reason but I wouldn't know looking at this code. Hope it helped a bit....

Hey guyz i have solved my problem of fetching data from tables based on column values and know i want to share the sloppy mistakes. TextView lblEmail = (TextView) findViewById(R.id.textView1); TextView lblReg = (TextView) findViewById(R.id.textView1); TextView lblName = (TextView) findViewById(R.id.textView1); This code has to be written like as stated below...

Do these go to the OS, where they are relayed to the place where they are needed Yes. After all, the majority of the time, the activity that is to be started does not presently exist. Also, on that note, can all Activity instances "listen" to all intents Activities...

You could use a BroadcastReceiver for this. private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { //Get all your music data from the intent String position = intent.getStringExtra("pos"); ... } }; Register this BroadcastReciever with an Intent in your NowPlayingActivity's onCreate() like this, registerReceiver(mHandleMessageReceiver,...

This is Showing that : PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); You are giving request code 0 to all notifications. 0 should be replaced by each unique number...

Well, you have a couple of issues. First, setRepeating() is inexact on Android 4.4 and higher, with a targetSdkVersion of 19 or higher. They do not state how "inexact" it actually is, and so I don't know when your alarms will get scheduled. Second, a repeating alarm period of less...

There are no message IDs or thread IDs in SMS. Each SMS is a data packet that is completely independent of all other SMS. In Android, there is a standard SMS application that stores SMS in a database and "threads" conversations using some criteria which is not contained within the...

You have to add an extra flag to close the email app first. Something with singletask or so. Try something like: intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); And have a look at yet more flags. ...

You're getting an error on the mActivity = (Activity)mContext; line because the Context you're instantiating the Adapter with is not an Activity. Change the Adapter instantiation as follows: mAdapter = new MyAdapter(this, TITLES, ICONS, NAME, EMAIL, PROFILE); ...

NFC events are triggered by touching an NFC tag. Hence, when you open your app by clicking the launcher icon (or by starting it from your development environment), ANdroid won't generate an NFC event (even if your device is was already placed on top of the tag). Hence, what you...

taggable_friends is for tagging friends only. Use /me/friends instead to get IDs. Of course you can only get friends who authorized your App too, that´s how it is now. Not sure if it even works with those IDs though, because those are App Scoped IDs and there is no way...

MapActivity is extend by Fragment Activity and inside this you are opening Map i.e also opening inside a fragment so you cannot make a call to map directly with help of intent. you can do this like as: ((MyFragmentActivity) getActivity()).replaceFragments(); and then inside fragment activity replace that fragment.

STEP 1 - Using an Implicit Intent: To choose a file from the device, you should use an implicit Intent Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT); chooseFile.setType("*/*"); chooseFile = Intent.createChooser(chooseFile, "Choose a file"); startActivityForResult(chooseFile, PICKFILE_RESULT_CODE); STEP 2 - Getting the absolute file path: To get the file path from a Uri,...

It seems quite unusual for Android to clean up an activity in the way you described, but if that was the case I would think that your activity should still be restored. The fact that you don't return to the original activity and you can see from your debugging that...

From Activity page ava.lang.Object ↳ android.content.Context ↳ android.content.ContextWrapper ↳ android.view.ContextThemeWrapper ↳ android.app.Activity We also need to note that Context is an abstract class, so we need to use some implementation because it is imposible to create an instance of an abstract class in java. And on this Context page you...

It looks like this was an issue for other people as well (see here). I checked the official GCM docs and indeed can verify that you'll need to place uses-permission outside the application tag. By the way, it looks like you are using the deprecated C2DM libraries. You might want...

First of all the TYPE_GYROSCOPE return angles are Radian angles, use: float azimuth = sensorEvent.values[0]*180/Math.PI; float pitch = sensorEvent.values[1]*180/Math.PI; float roll = sensorEvent.values[2]*180/Math.PI; Second, You do not start Activity as i can see, just trying to set text. Edit: If that is your indicator for phone's orientation , make an...

You could try starting the recording in a plain old Service in the onStartCommand(...) callback, and making your PendingIntent to start recording start this service. To stop the service, you can't make a PendingIntent that stops a service, so you'd have to get creative, and could use a BroadcastReceiver to...