Menu
  • HOME
  • TAGS

Simplest way to use / create a PendingIntent

android,android-intent,android-pendingintent

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...

Alarm receive don't work

android,android-intent,android-service,android-pendingintent,android-broadcast

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. ...

Android - unable to retrieve Intent when Activity is set to Single Top

android,android-intent,android-activity,android-task

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...

Facebook API v2+. Open Facebook application (friend profile or chat page) from my android app using intent?

android,facebook,facebook-graph-api,android-intent

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...

How are android intents handled at runtime?

android,android-intent,android-activity

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...

i need to calculate fine to pay for late submission of books in library? [closed]

android,android-layout,android-intent,android-fragments,android-activity

How about the following: double finePerDay = ...; Calendar dueDate = ...; Calendar now = Calendar.getInstance(); int daysLate = Math.max(0, TimeUnit.MILLISECONDS.toDays (dueDate.getTimeInMillis() - now.getTimeInMillis())); double totalFine = finePerDay * daysLate; ...

Cannot resolve constructor Intent

android,android-intent,android-tabhost

The first parameter to the Intent constructor that you are trying to use takes a Context. Fragment is not a Context. Use getActivity() instead of this.

Android Intent doesnt work

java,android,android-intent

Use passed intent variable in onNewIntent protected void onNewIntent(Intent intent) { handleIntent(intent); } You should also remove call to handleIntent from within handleIntent method...

Start and stop recording from a button in a notification

android,android-intent

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...

Starting new Activity not from the MainActivity file

android,android-intent,android-fragments,android-activity

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);

opening notofication from gcmIntentClass to a fragment class

android,android-intent,android-fragments,android-gcm

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); ...

Return a String from a Thread Android Java

java,android,multithreading,android-fragments,android-intent

You can do something like this. String str_Data = ""; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.MainActivity); String str_Name = ""; str_Name = setDataToText(str_Url); } private String setDataToText(String urlStr) { new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub //A code to retrieve data is executed...

Getting the Foreground Activity of any application in a Service written in other application

android,android-intent,android-activity,service,intentservice

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....

How to open “zxing Barcode” scanning screen in a small window?

android,android-intent,android-camera,zxing,barcode-scanner

You may use Journey's Library. You can use the scanner as a component just like an image or a text. It's based on ZXing. =)

The method getIntent() is undefined for the type GetLRL

android,android-intent

GetLRL class must be an Activity (extends Activity), if it is not, then the undefined method exception will be thrown

Launching email client programatically in android and passing email address to client

android,email,android-intent

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. ...

Pass 3D-array to Activity in Android

android,android-intent,android-activity,multidimensional-array

I'm pretty sure double[][][] doesn't implement Serializable. What you can do is make your own class like so: public class MyArrayWrapper implements Serializable { private double[][][] arr; public MyArrayWrapper(double[][][] value) { arr = value; } public double[][][] getArray() { return arr; } } You then instantiate that wrapper class and...

How to set an image on imageView from the gallery and image taken by camera in Android?

android,android-intent,android-imageview,android-bitmap

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

Get IntentSender object for createChooser method in Android

android,android-intent,android-pendingintent

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...

Crop Image Located in Internal Storage

android,image,android-intent,crop,android-fileprovider

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...

Intent can't move to another activity using IF

android,sockets,if-statement,android-intent,client

Change your if condition as if(thread.Socketdata.toString().equals("OK")){ Intent i = new Intent(MainActivity.this,LOGIN.class); startActivity(i); } and check....

Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference

android,android-layout,android-intent,android-activity

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....

Is it possible to know whether another app is in background or foreground?

android,android-intent

Firstly, AFAIK, at a time, only one application can be in foreground mode. That means, if you run your application (task manager), it will be in foreground mode and other application that were running will be in background mode until they are being killed. So you don't have to list...

Android parentActivity not getting recreated after startActivityForResult returns

android,android-intent,android-fragments,android-activity

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...

how to fetch all column Values based on Email

android,sqlite,android-intent,homescreen

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...

Android: Edit an image by 3rd party app / Intent ACTION_EDIT

android,cordova,android-intent

Disregard this one. Started from scratch again and it seems to be working.

Android Intent and Intent filter

android,android-intent,intentfilter

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...

Changing activity from other app android

android,android-intent,intentservice,oncreate

I solved this with Service public class RepeatClass extends Service { private static final String TAG = "ServiceTag"; private boolean isRunning = false; @Override public void onCreate() { Log.i(TAG, "Service onCreate"); isRunning = true; } @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "Service onStartCommand"); //Creating new...

I'm trying to get location on android device But it crashes immediately after execution

android,android-intent,android-activity

This might help u, Thread thread = new Thread(new Runnable() { @Override public void run() { try { URL url = new URL(url); HttpURLConnection conn = (HttpURLConnection) url .openConnection(); conn.setReadTimeout(10000 /* milliseconds */); conn.setConnectTimeout(15000 /* milliseconds */); conn.setRequestMethod("GET"); conn.setDoInput(true); // Starts the query conn.connect(); InputStream stream = conn.getInputStream(); String data...

Unable to Register Android App with GCM : Not allowed to start service Intent

android,android-intent,android-gcm

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...

Android - No suitable constructor found

java,android,android-intent,android-fragments,android-activity

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); ...

Start intent when pitch us between 0 and 135 Android

android,android-intent,android-sensors

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...

Android Receive SMS Intent: Get Message Id or Thread Id

android,android-intent,telephony,smsmanager

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...

Bluetooth pairing - how to show the simple Cancel/Pair dialog?

android,android-intent,bluetooth,android-bluetooth,bluetooth-oob

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...

Getting arguments from a bundle

android,android-intent,android-fragments

This is a correct approach Send (in the Activity): final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); final DetailActivityFragment frg = new DetailActivityFragment (); ft.replace(R.id.container, frg); final Bundle bdl = new Bundle(); bdl.putString("yourKey", "Some Value"); frg.setArguments(bdl); ft.commit(); Receive (in the Fragment): final Bundle bdl = getArguments(); String str = ""; try { str...

Is it secure to pass PIN via bundle/extras in Android?

android,android-intent,android-activity,android-bundle

On rooted device something can modify the framework to intercept Bundles so risk is higher than on non-rooted devices.

Android : AlarmManager is not wroking properly. It is not able to set the alarm

android,android-intent,alarmmanager,android-pendingintent

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); ...

Choosing photo using new Google Photos app is broken

android,android-intent,android-gallery,google-photos

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...

Use OnclickListener In custom Adapter Class

android,android-intent,listadapter

Use Activity instead of context beceause your Context is null, you are not assigning anything to Context in constructor but you are assigning values to Activity holder.replyEdittext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent replyClassIntent = new Intent(activity,Reply_Class.class); activity.startActivity(replyOzoneIntent); } }); ...

How to resolve Out of Memory Error on Bitmap in Android?

android,android-intent,android-activity,bitmap

use following method..... **************************************************** Bitmap bm = ShrinkBitmap(imagefile, 300, 300); image.setImageBitmap(bm); Bitmap ShrinkBitmap(String file, int width, int height) { BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options(); bmpFactoryOptions.inJustDecodeBounds = true; Bitmap bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions); int heightRatio =(int)Math.ceil(bmpFactoryOptions.outHeight/(float)height); int widthRatio =...

How to get position of listitem using setonitemclicklistener and send to next activity

android,listview,android-intent

Just you need to pass your HashMap Arraylist to next Activity. Like, intent.putExtra("myList",arraylist_oper); and in your next Activity just retrieve as Intent intent = getIntent(); ArrayList<HashMap<String,String>> mylist = (ArrayList<HashMap<String, String>>)intent.getSerializableExtra("myList"); EDIT : You need to pass your qrCode too next Activity intent.putExtra("qrcodes", arraylist_oper.get(position).get("qrcode"))); Now retrieve in next activity as String...

take screenshot from layout and share via android

android,android-intent,bitmap

Please use this code this is tested code : public static void takeScreenshot(Context context, View view) { String path = Environment.getExternalStorageDirectory().toString() + "/" + "test.png"; View v = view.findViewById(android.R.id.content).getRootView(); v.setDrawingCacheEnabled(true); v.setDrawingCacheEnabled(true); Bitmap bitmap = Bitmap.createBitmap(v.getDrawingCache()); v.setDrawingCacheEnabled(false); OutputStream out = null; File imageFile = new File(path); try { out = new...

Multiple notification handling

android,android-intent,notifications,android-pendingintent

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...

how to pass data intent in different textview in android

android,android-layout,android-intent

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...

Unable to launch list view owing to constructor error

java,android,android-intent,android-fragments,android-activity

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....

Cannot start activity using explicit intent

android,android-intent

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" /> ...

Broadcast intent vs multicast listener implementation on Android

android,android-intent,listener,broadcast

You may try LocalBroadcastManager, which is a lightweight solution for sending broadcast intents, and it is a part of Android support library v4.

Android Notification: Intent.FLAG_ACTIVITY_NEW_TASK required?

android,android-intent,notifications

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...

On Android M, how to configure the “direct-share” capabilities (image, text), and how to query the items?

android,android-intent,android-manifest,android-m,direct-share

Question 1 In the description, they only show what to put in the manifest, and they mention using "ChooserTargetService". What should be done in order to provide the texts and images? Start by extending ChooserTargetService. You'll need to return a List of ChooserTarget and how you create those targets is...

RuntimeException when loading image from device and applying parallax effect

android,android-layout,android-intent,android-activity,android-xml

I think the problem is here: Button buttonLoadImage = (Button) findViewById(R.id.buttonLoadPicture); You should use this Button buttonLoadImage = (Button) view.findViewById(R.id.buttonLoadPicture); Because the header is not added into the activity layout yet, so your currently code will get a null pointer when find buttonLoadPicture....

Save intent Extras

android,android-intent,android-activity,activity-lifecycle

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...

Difference between PendingIntent.send(…) and Activity.startIntentSenderForResult(…)

android,android-intent

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...

Making a layout clickable, and start an intent

java,android,xml,exception,android-intent

Do the change in your xml like below code: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#0D47A1" android:id="@+id/mylayout"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:text="sometext"/> </RelativeLayout> And in your activity like this RelativeLayout relativeLayout; public class YourActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) {...

How do I configure my AlarmReceiver to actually trigger at my desired interval?

android,android-intent,alarmmanager,android-alarms,repeatingalarm

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...

Sending Intent from BroadcastReceiver class to currently running activity

android,android-intent,android-activity,android-bundle

you have three ways: 1) you can define your broadcast inside your MainActivity like this: in onCreate() registerReceiver(smsReceiver, new IntentFilter(SMS_RECIEVED)); and define smsReciver in MainActivity private BroadcastReceiver smsReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //you can update textBox here handler.postDelayed(sendUpdatesToUI, 10); } }; define...

I want to Show Simple Toast Message When User Click On Media Controller button Pause/Start/Stop in video View Using Media Controller

android,android-layout,android-intent,android-fragments,android-activity

Check the videoView state like: if(videoView.isPlaying()){ Toast.makeText(context, "Paused", Toast.LENGTH_SHORT).show(); } ...

How to send a WifiP2pManager object though a Parcelable interface to another activity

android,android-intent,wifi-direct

After figuring out that we cannot send such objects via intents, i tried to share data between my activities, so static SharedData Class is born in my MainHomeActivity. public static class SharedData { private static WifiP2pManager mManager; private static WifiP2pManager.Channel mChannel; static public void set(WifiP2pManager m, WifiP2pManager.Channel c) { mManager...

Open Map Activity from GCM Push Notification

android,android-intent,android-activity,android-gcm,android-location

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.

Android - No view found for fragment

java,android,android-intent,android-fragments,android-activity

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...

Android Studio - Illegal character 8204 error

java,android,android-intent,android-fragments,android-studio

Try changing your encoding, see the image: ...

Back to a fragment from fragmentActivity in Android

android,android-intent,android-fragments,android-fragmentactivity

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...

Dealing with Fragment and listView and JSON

android,android-layout,android-intent,android-fragments,android-activity

I fixed it by the following: Moving the followings to the fragment : private ListView mListView; private ListViewNewsAdapter listViewNewsAdapter; private ArrayList<ListViewNewsItem> listViewNewsItems; private JSONParser jsonParser = new JSONParser(); private String READNEWS_URL = "xxxxxxxx.xxxxx.xxxxx"; public CreateFragment() { // Required empty public constructor } Then, inside the onCreateView I created : mListView...

How to click song list (Now Playing activity) to playing without (Music Preview) startActivity

java,android,android-intent,android-activity,android-developer-api

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,...

Implementing a File Picker in Android and replicating the selected file at another location

android,android-intent,android-file,android-fileprovider,android-implicit-intent

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,...

Is it possible to share multiple text by using share intent?

android,button,android-intent,share

Could anyone help ? Concatenate the six strings into one larger string, and share that larger string....

Use one instance of MediaPlayer throughout several fragment classes

java,android,android-intent,android-fragments,android-mediaplayer

You can use the Singleton Pattern: public class Singleton { private static Singleton mInstance = null; private String mString; private Singleton(){ mString = "Hello"; } public static Singleton getInstance(){ if(mInstance == null) { mInstance = new Singleton(); } return mInstance; } public String getString(){ return this.mString; } public void setString(String...

How to getCropAndSetWallpaperIntent(Uri imageUri) to work?

android,android-intent,uri,android-wallpaper

Like the error says, you need a content URI. Content URIs allow you to share files with temporary read and write permissions. Check out: Get a Content URI from a File URI?...

how to launch an image in a activity by clicking a button in a diffrent activity in android studio

android,android-intent,android-studio

You should use activity result to deal with it: in MainActivity: public void onClick(View v) { Intent intent = new Intent(this, MainActivity2Activity.class); startActivityForResult(intent, PERFERENCE_CODE); } // React to complete edit @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to if (resultCode ==...

SigninActivity is not an enclosing class

java,android,class,android-intent,android-activity

You are doing mistake in your onPostExecute(String result) method. Replace Intent intent3 = new Intent(SigninActivity.this, MainActivity.class); startActivity(intent3); By context.startActivity(new Intent(context, MainActivity.class)); ...

BroadcastReciver class not running

android,android-intent,broadcastreceiver,intentfilter

Change your action in android manifest to : <action android:name="android.intent.action.ACTION_POWER_CONNECTED" /> <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" /> ...

Android: Intent asks remove argument & getBaseContext() ask to create its method

android,android-intent,android-fragments

import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.widget.ImageButton; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; public class postingActivity extends Fragment { private ImageButton infrastructure; private ImageButton trafficjam; private ImageButton others; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle...

How to check for existing activities when back button pressed

android,android-intent,android-activity,stack

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...

I need to start activity using my SearchView widget on my actionbar

java,android,android-layout,android-intent,android-activity

My guess is that you chose the wrong import, You should import import android.support.v7.widget.SearchView; instead of import android.widget.SearchView; ...

The constructor Intent(new View.OnClickListener(){}, GetLRL) is undefined

android,android-intent

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...

How to mock a Android NFC Tag object for unit testing

android,unit-testing,android-intent,mocking,nfc

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...

Passing HashMap using intent returns null, why?

java,android,android-intent,hashmap

I believe there is a typo here: Intent intent = getIntent(); players = (HashMap<Integer, Player>) intent.getSerializableExtra("player"); Did you mean: getSerializableExtra("players"); ...

Tag returns null when trying to write NDEF message to NFC tag - Tag is not detected

android,android-intent,tags,nfc,ndef

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...

How does “this” actually provide a Context from an Activity when used in for example an Intent(this, ClassName.class)

java,android,android-intent

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...

Passing Number[] array through Intent

android,arrays,android-intent,bundle,androidplot

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

Android Implicit Intent for Viewing a Video File

java,android,android-intent,uri,avd

Change your onClick method to below code. You should give the option to choose the external player. @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("https://youtu.be/jxoG_Y6dvU8"), "video/*"); startActivity(Intent.createChooser(intent, "Complete action using")); } ...

Clear back stack but keep transition animations

android,android-intent

Change your code to public class TaskActivity extends FragmentActivity { private void launchNextTask(Task nextTask) { Intent intent = new Intent(TaskActivity.this, TaskActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(TASK_KEY, nextTask); startActivity(intent); overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } } And it should fix your issue....

How to determine which Activity launched current Activity in Android?

android,android-intent,android-activity

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()...

open application After incoming or outgoing call diconnection

android,android-intent,android-listview,broadcastreceiver

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...

Android: Using an intent to start any activity

java,android,android-intent,android-activity

Since Intent constuctor accepts the component class as its parameter, it's as simple as this: context.startActivity(new Intent(context, Class.forName("com.example.area.Triangle_Area")); ...

Sync Adapter not calling onCreate

android,android-intent,android-activity,android-service,android-syncadapter

Sync adapter starts explicitly by calling: ContentResolver.requestSync(ACCOUNT, AUTHORITY, null); or similar method: ContentResolver.addPeriodicSync( ACCOUNT, AUTHORITY, Bundle.EMPTY, SYNC_INTERVAL); https://developer.android.com/training/sync-adapters/running-sync-adapter.html I strongly recommend this book, especially first 200 pages http://www.wrox.com/WileyCDA/WroxTitle/Enterprise-Android-Programming-Android-Database-Applications-for-the-Enterprise.productCd-1118183495.html ....

Android App crashes when intent a new activity

java,android,android-intent

Have you added the new Activity to the manifest file? Add this <activity android:name=".Dashboard" android:label="Dashboard" /> ...

Notification not always starting the Activity

android,android-intent,android-activity

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....

Unable to check if alarm has been set by AlarmManager

android,android-intent,service,alarmmanager

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...

prevent asynctask to run after intent and starting the activity

android,android-intent,android-asynctask

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,...

How do I avoid multiple apk install promps on an Android programmatic install?

android,android-intent,apk

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...

Using intent between activities, in reverse - Android

java,android,android-intent,input,android-studio

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...