FAQ Database Discussion Community


An activity with two listviews in android

android,android-layout,android-activity,layout,android-listview
MainAcitivity public class MainActivity extends Activity { ListView list, listYear; String[] web = { "Google Plus", "Twitter", "Windows", "Bing", "Itunes", "Wordpress", "Drupal" } ; String[] year = { "2012", "2013", "2014", "2015", "2016", "2017", "2018" } ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); list=(ListView)findViewById(R.id.list); list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, web));...

windowSoftInputMode has no effect in Android M

android,android-activity,android-dialogfragment,android-m
I have a MainActivity with android:windowSoftInputMode="adjustNothing" set in the AndroidManifest. The Theme has parent Theme.AppCompat.Light.NoActionBar. I add a DialogFragment to this activity and show an AlertDialog inside of it, then set alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); inside the fragment. Now, on Android 5.1.1 it works as expected. The keyboard does not auto show when...

Why does this run out of memory? Shouldn't the Activities be released?

android,android-activity
A project with only the following two activities will throw an OutOfMemoryError. Why does this happen? Shouldn't the older activities on the stack be released when memory is nearing the limit of the heap? public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); startActivity(new Intent(getApplicationContext(),...

How to call a fragment using a dialog

android,android-fragments,android-activity
I have a dialog extended class. I want to call a fragment to be displayed on a click of a button. I am using this method: public void onClick(View v) { dismiss(); SearchingFragment mySearchengine = new SearchingFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, mySearchengine); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); }...

How to free previous intent when calling startActivity() with new intent

android,android-activity
I am facing this issue: Create intent from an Activity Then at Home screen, I call startActivity with this intent After I startActivity with intent A then intent B, the intent A still remain behind I want: free intent A when I startActivity with intent B press BACK from any...

Good approach to clean application data programmmatically in Android

android,android-fragments,memory,android-activity,picasso
When I use RecyclerView and/or Picasso. It seems to cache and store alot of data in my application. However, I want to delete the stored data and the cache in a simple way whenever I am exiting my app. What is the simplest way to delete all data stored in...

None linear activity transition animation

android,android-activity,android-animation,android-transitions
I want to implement a none linear activity transition animation. My current anime xml file <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="@android:integer/config_mediumAnimTime"/> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_mediumAnimTime" /> </set> What i want to do is animation to start slow end in faster speed....

How are android intents handled at runtime?

android,android-intent,android-activity
I understand that intents are used to start new activities and services and can contain information about these - certain UI options, etc. They can be emitted by some activities or apps to signal that others should begin or end, or that some change should occur. I don't understand how...

Android: Using an intent to start any activity

java,android,android-intent,android-activity
I have been working on an application that has a bunch of formulas in it. The user can select which formula they need to use, input the numbers/variables, and the program will return whatever answer they are looking for. Each formula has its own class and since there are so...

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. Basically I have written a service and I want to get the reference to the "current" foreground activity in that service. With "current" I mean any application activity other...

How to close a VideoView Activity (currently have to press back twice)

android,android-activity,android-mediaplayer
I have a simple Activity to preview a video in FullScreen. The layout of the Activity is: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black" android:fillViewport="true"> <VideoView android:id="@+id/video" android:layout_width="wrap_content" android:layout_height="wrap_content"...

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
Unable to pass data from one fragment to another using intent. Logic is fine .Please check the last parts of main activity where I have sent strings to other activity using putExtra. Here is the MainActivity.java : public class MainActivity extends Activity implements View.OnClickListener { EditText ed1,ed2,ed3,ed4,ed5,ed6; Button bt1; TextView...

Andoid title or Android action bar went missing while using “Extends Activity” [closed]

android,android-activity
Anyone know why my action bar/ my android title bar is missing when I extends Activity? All this while it is working fine and the action bar/ title activity is being shown on the activity whenever I used extend activity. I have been using extend activity for a very long...

When are the default Looper and handler in main thread created

android,android-activity
For the main activity, looper and handler from the main thread handle the user inputs in the UI. Since the main activity is granted one thread, when are the looper and handler created? Is there a way to see how the underlying are implemented when it receives message from the...

onActivityResult not being called when launching another app

android,android-activity,onactivityresult
I am trying to call another app through intent, the app is called but the onActivityResult is not being called. Could someone please help me on this? Below is my code: public class EncryptCommandActivity extends Activity{ EncryptionFactory encryptionFactory = new EncryptionFactory(); protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.encrpyt_command_activity); ActivityContexts.setEncryptCommandActivityContext(this); Intent...

Android: When I save a file in the phone's internal memory will store Where's that file? How can I access it path?

android,android-activity,path,android-sdcard
we have 2 memories for store files: 1- phone memory 2- sd card memory now : I can access to files and roots in sdcard memory with Environment.getExternalStorageDirectory ... and return : /storage/sdcard0 this is ok. but : When i store files and media (music,pic, ...) in phone memory, how...

Removing Activity from BackStack (Flag_Activity_no_history) does not work

java,android,android-activity,back-stack
I've a Start button in my MainActivity. If I click on this button I go to the next Activity (InfoActivity). Now, I want to remove the MainActivity from the BackStack, if I click on the button. I've tried this: View.OnClickListener startButtonListener = new View.OnClickListener() { public void onClick(View v) {...

Android: status bar not theme on transitiong to new activity

android,android-activity,android-5.0-lollipop,statusbar
I have create a simple app with 2 activities. Main (launcher) activity is themed properly where colorPrimaryDark is applied to status bar. But when I transition to new activity, everything seems normal except status bar. It somehow colored white. Any idea why this could be happening? Running this on OnePlus...

Dealing with Fragment and listView and JSON

android,android-layout,android-intent,android-fragments,android-activity
I am trying to make an application with MenuDrawer that contains 4 fragments. This is how my application show do. When it starts, it should retrieve data from a website. The retrieved data should be in a listview in the first fragment. The second fragment should contain a webview to...

Sending Intent from BroadcastReceiver class to currently running activity

android,android-intent,android-activity,android-bundle
I have a class which extends BroadcastReceiver. On receiving a SMS, I would like to pass information to my main activity class to display the text in a box (Append, if already text is present). public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent...

Android MediaPlayer playing sound ok on virtual device and on tablet, but intermittently on smartphone galaxy s iii mini

android,android-activity,android-studio,android-mediaplayer,samsung-mobile
I'm using the following code in onCreate() mPlayer = MediaPlayer.create(this, R.raw.rain); mPlayer.start(); No problems in virtual emulator nor in tablet galaxy tab, but when I try on my Galaxy S 3 mini it plays the sound intermittently, my logcat looks like this: 06-11 12:48:04.253 5579-5579/? D/dalvikvm﹕ Late-enabling CheckJNI 06-11 12:48:04.573...

Add login Activity afterwards

java,android,android-activity
I started my android app by making a ListViewActivity. Now I decided to make a LogInScreenActivity. Do i have to declare the LogInScreenActivity as MainActivity? Or can i change the MainActivity manually? I'm using Android Studio and new ad Androidl...

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

android,android-intent,android-activity,bitmap
I want to set an image in image view,I am retrieving the image path in my first activity and I am passing it via intent as a String to second activity.In the second activity I set the path to an image view,It is working properly , and I need to...

Notification not always starting the Activity

android,android-intent,android-activity
Per title, it doesn't always start the activity. There's no error in output log, it just says 06-01 16:46:36.924: I/ActivityManager(370): START u0 {flg=0x10000000 cmp=com.myapp/md527315440e30c82eb86ffbe7caee6cb98.MyView bnds=[96,712][1056,840] (has extras)} from pid -1 What I mean by "not always" is this: I start app, it shows the main screen. Notification is received, I...

Are Application.ActivityLifecycleCallbacks synchronously called before the lifecycle methods in the Activity?

android,android-activity,android-lifecycle
I've inherited some nice looking code that uses Application.ActivityLifecycleCallbacks. We're using the onActivityResumed method to take users back to a login screen when their session has timed out. There's no documentation in the API docs about how this works. Do we get any guarantees about when these methods are called...

Android - No view found for fragment

java,android,android-intent,android-fragments,android-activity
I'm trying to get my replaced fragment to appear in the detail fragment but after debugging my app on a tablet emulator and selecting the necessary list view item, the log cat gives me this error: Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f0c0050 (com.apptacularapps.exitsexpertlondonlite:id/detail_container) for fragment FragmentWCBank{3b4ea8fb #0...

How to delete the complete view on click of delete button in android

android,android-layout,android-activity,android-listview,android-arrayadapter
I have made a custom view that contains an image,text and a delete button. I want to delete the the particular view when I click the delete button associated with it. Please tell how to implement this. Here is my MainActivity.java package com.khurana.nikhil.list1; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.LayoutInflater; import...

How to put file from android app to pc in LAN network

android,android-activity,share,pc
I have a little problem with my android app. I'm developing an android app that should read .txt file from PC, and path is "E:/Sharing/hello.txt". I already shared that folder on PC. How can I get that file and read it on my android app. Is there any solution, or...

how to understand onOptionItemSeleted()

java,android,android-activity
I am fairly new to android.Recently I have been following this tutorial about making a navigation drawer for my app. Most of it seem pretty straightforward(http://blog.teamtreehouse.com/add-navigation-drawer-android). However,I am confused about what role onOptionItemSelected plays in the activity. if (mDrawerToggle.onOptionsItemSelected(item)) {return true;} if I remove the code above , the navigation...

Can Activity classes be made launchable only during development/debug?

android,android-activity,android-view,android-testing
A common situation I face is that I wish to test a custom View visibly on screen while it is being developed as part of a large application. I realise that unit testing exists, particularly using ActivityUnitTestCase, but as far as I understand these frameworks don't actually attach the components...

How to check for existing activities when back button pressed

android,android-intent,android-activity,stack
Generally, when the back button is clicked, I call finish(), and I am taken back to the previous activity (which is my MenuActivity) : @Override public void onBackPressed() { finish(); } However, sometimes the there are no other activities running when the back button is clicked and the app simply...

Save intent Extras

android,android-intent,android-activity,activity-lifecycle
I have 3 activities 1st activity calls 2nd activity and the 2nd activity calls the 3rd activity. 2nd activity uses intent extras from the 1st activity. So when I return (using actionbar back button) to 2nd activity from the 3rd activity, I get a nullpointerexception on the place where i...

Using Getters and Setters in Base Activity Android

java,android,inheritance,android-activity
I made a generic activity which I am extending from in my main activity. I want to be able to change the String Variable in the base activity. See below. public abstract class BaseActivity extends ActionBarActivity { private String name; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sidedrawer); TextView tv=(TextView)...

Need up to date way to implement activity with tabs connect to fragments? while ActionBar.TabListener is deprecated, TabLayout can't be resolved

android,android-fragments,android-activity,android-tabs
I need activity with multiple tabs that connect to fragments. I have found using ActionBar.TabListener, however, it is depreciated in API Level 21. Also, when using TabLayout, Android Studio tells me it can't resolve it!! Can anyone suggest a more up to date way to do this?...

Moving from one ListView to another ListView

android,listview,android-activity,android-listview,listactivity
I am new in android development and create list item here is my code of both classes. I am trying to move from Menu to another activity(Prepaid) which also implemented list view. Problem is it can not move to Prepaid activity. Also my Header is missing from menu class, how...

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

android,android-intent,android-activity,android-bundle
I need to ask the user to enter his app pin and confirm that pin by entering it again. I am not going to save that pin on the device and will sent it on server as soon as I get it. While implementing confirmation screen, this question came into...

Registering “onDestroy event handler” with Android Activity

android,android-activity,ondestroy,eventhandler
Let's say I have a library object which needs to be notified of an Activity.onDestroy() event if it happens. Is there a way that I can register some sort of handler with the Activity from inside the library or will I need to require anyone using the library to override...

Can I remove the activity without UI from bach stack?

android,android-activity
Can I remove the activity without UI from bach stack? I have a activity ShareAct which without UI to contain the share logic use Facebook sdk. The ContentAct is the activity to show the content. ContentAct -> ShareAct -> Facebook sdk The ShareAct has no view but onActivityResult() method to...

Android Full Width in Video View

android,android-layout,android-activity,videoview,android-videoview
I am trying to stretch my video view inside the linear layout or relative layout to full screen but the application does not stretches the width of the video view same to android screen. There is always 10 to 15 dp space on left and right each. Also the Linear...

Logcat showing WindowLeaked

android,android-activity,android-logcat
Even though there are no crashes in my app. But logcat showing this debug log. I wanna know what thing causing this problem. I don't much about threads so may be this is related to lousy use of threads. 06-12 12:37:37.349 12433-12433/com.ets.medecord E/WindowManager﹕ Activity com.ets.medecord.LoginActivity has leaked window [email protected] that...

Android use AppBarLayout instead of Toolbar

android,android-activity,toolbar,android-support-library,appcompat
I am using a normal AppCompat Toolbar in my project. In one of my fragments I want to use the AppBarLayout toolbar and TabLayout instead of the normal Toolbar. How can I switch between those two toolbars? I tried inflating the AppBar Toolbar but it just puts it below the...

Correct way and location to initialise adapter

java,android,android-activity,android-adapter,android-listfragment
I'm trying to setup a filter for my list view but I've come across these errors. Cannot resolve symbol 'myAdapter' I know that myAdapter hasn't been initialised, but I don't know which of my classes I need to declare it in. error: method setOnQueryTextListener in class SearchView cannot be applied...

Keep HashMap with object data while app is idle - Android

android,android-activity
I have a HashMap that contains data relevant to a specific Activity. The problem is that when the app is opened after being idle for some time, the HashMap is empty. I am fetching all the data in the main activity and storing the corresponding objects in a HashMap in...

Application Unfortunately stopped when going from 2nd activity to 3rd activity

android,android-layout,android-activity,android-studio
I'm new to Android developing. This is an assignment which was given to me. I have to convert the value and the converted value must be shown in the next activity. But when I press the submit button its crashes.I don;t know what is the problem. Is there a problem...

Make clickable item of listview in drawer navigation

android,listview,android-activity
I have used the below code for my navigation drawer which is used and included in several activities by including the layout and create object and calling the function. I want to add functionality to it, when one item clicked, it starts new activity. <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"...

Android - No suitable constructor found

java,android,android-intent,android-fragments,android-activity
After rebuilding my project I get this error: Cannot resolve constructor 'Intent(anonymous android.widget.AdapterView.OnItemClickListener,java.lang.Class>)' Does anyone what the error means, what is wrong with the constructor and how do I resolve this issue? public class FragmentWCLine extends android.support.v4.app.Fragment { public final static String EXTRA_MESSAGE = "Station_key"; private class WC { private...

How to determine which Activity launched current Activity in Android?

android,android-intent,android-activity
Without using an Intent and passing an extra parameter, is it possible to determine which Activity launched the current Activity?

how to add menu items to action bar in more than 30 activities

android,android-activity,android-studio,menu,menuitem
I have created an app in android studio that has more than 30 activities .I created menu items in some activities by adding them in individual menu files and they worked fine . But the problem is that it is a real headache to add all the menu items in...

How To Update a layout in onActivityCreated() of Fragment

android,android-layout,android-fragments,android-activity
I am inflating a layout in onCreateView() of the Fragment,On the Activity created() of the Fragment,I am retreving the data from the DataBase and updating the values in the layout from the DataBase which i inflated earlier. LinearLayout main = null; if (rootView instanceof LinearLayout) main = (LinearLayout) rootView; main.removeAllViews();...

How can i take a picture with custom camera and display it on another activity?

android,android-activity,camera,photo
Please help me how to take a picture from a custom camera and display it on another activity, please give me more detailed answer, what code should i put, and where, please tell me if what kind of variables, int, strings, booleans should i create, here is my code :...

Project has no project.properties file! Edit the project properties to set one and already error when create any project

android,android-layout,android-activity
There are many answers on this question on this site but i think non of them are work with me and here's errors: [2015-06-13 19:37:02 - appcompat_v7] Project has no project.properties file! Edit the project properties to set one. [2015-06-13 19:37:02 - appcompat_v7] Project has no project.properties file! Edit the...

Android: clarification on opening activities and buttons

java,android,android-activity
I'm learning android development and I need a hint on the inner working of the whole thing. I'm using the code showed here In public void sendMessage(View view) { Intent intent = new Intent(this, DisplayMessageActivity.class); } I want to know what "this" is In the guide I read: A Context...

My class extends ActionBarActivity for full screen How to Hide and show the ActionBar on touch event

android,android-activity
I am new to android, help me. When I click an image, it will show in full screen but on touch it is not showing ActionBar and if I touch it should hide ActionBar also in full screen mode public void startFullScreen() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().getDecorView().setSystemUiVisibility(...

Sync Adapter not calling onCreate

android,android-intent,android-activity,android-service,android-syncadapter
Do we need to start the Sync Adapter service or framework starts implicitly? I have put a log on Constructor, onCreate, onDestroy of Sync Adapter service and when I start the app, I don't see the logs in the logcat. But when I do on activity onCreate Intent serviceIntent =...

Open Map Activity from GCM Push Notification

android,android-intent,android-activity,android-gcm,android-location
I am trying to open a specific activity called 'MapActivity' where I want to load my current position on a map and get nearby places. I got that working and also got GCM working to send push notifications to my device (Android 4.3). The only problem left is opening that...

Serializing execution of multiple fragments using AsyncTask

android,android-activity,android-asynctask,fragment
I'm having an activity with 2 fragments, called A and B. Fragment A has an AsyncTask to parse some data from the internet into an array of custom objects and fill its interface. Fragment B also has to use this array to update its interface. The question is, how can...

Unfortunately , appname has Stopped

android,android-activity,android-radiogroup
I am Trying to make a simple android program that starts the mainActivity and when the user clicks on the button the secondActivity Opens and shows a radio Group with three radio Buttons. When the user clicks on the radio button and press the button the string passed to the...

How To Use Same LinearLayout In Different Activities

android,android-activity,android-linearlayout
I want to use same LinearLayout in different activities. Selected LinearLayout's id in picture is previewLinear. What I want to do is, use previewLinear in a different activity. I have A and B activities. Firstly I do some changes for previewLinear in activity A (adding border, slice it to pieces...

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

android,android-intent,android-activity,android-task
I'm developing an app with the following scenario: Activity A -> Activity B -> Activity C -> Activity A I pass my values between each Activity through the Intents, and it works, but when I come back to Activity A, it seems all values are cleaned. Code from Activity C...

Countdown Timer Notification

android,android-activity,android-studio,background,countdowntimer
I'm begginer in Android programming, I have to do a CountdownTimer that starts from a number selected by the user using a two number pickers (one for Hours and other for minutes). The characteristics must be: -The CountdownTimer must work in background and notify the user when it arrives to...

Toolbar when extending Activity

android,android-activity,android-actionbar,appcompat,android-toolbar
I need to extend Activity and not ActionBarActivity or AppCompatActivity in order to use a third party library. In all the app I've been using AppCompatActivity in order to easily add a Toolbar in it, but apparently I cannot do the same if I extend Activity. I'd be also happy...

How to handle multiple fragment interaction listeners in one Activity properly?

java,android,android-fragments,android-activity,android-fragmentmanager
I have one Activity and six different Fragments attached to it. Each fragment has OnFragmentInteractionListener interface and activity implements all these listeners in order to receive callbacks. It looks a little messy, so I'm interested are there some patterns/ways to simplify this and make more elegant?

Display Checkbox field from MySQL in Android

php,android,mysql,android-activity,android-tablelayout
I have a MySQL database that has some yes/no fields that are set up as TINYINT(1) in mysql. I'm displaying information from that table into a table layout on android. How do I get those fields to show as a checkbox in android since the values in those fields are...

event.getSource() returns null Accessibility in android

android,android-activity,accessibility,accessibility-api
i am trying to fill EditText filed using accessibility service like DashLane or some other apps which are using accessibility Service. i am using an event view focused. when EditText gets focused the event getting started but getSource() returns null. Code is: AccessibilityNodeInfo source = event.getSource(); if (source != null)...

Unable to launch list view owing to constructor error

java,android,android-intent,android-fragments,android-activity
I'm trying to get my list view to appear but it won't don't do so when running my app due to a constructor error that I don't know how to fix. How can this issue be resolved? FragmentWCLine.java public class FragmentWCLine extends android.support.v4.app.Fragment { ListView listView; private class WC {...

event.getSource() returns null on View_Focused using Accessibility in Android

android,android-activity,accessibility
i am trying to fill EditText filed using accessibility service like DashLane or some other apps which are using accessibility Service. i am using an event view focused. when EditText gets focused the event getting started but getSource() returns null. Code is: AccessibilityNodeInfo source = event.getSource(); if (source != null)...

Set portrait only orientation on devices with a screen size of less than 7 inches

java,android,android-layout,android-activity,android-orientation
I am creating an android application that I want to: Run portrait only orientation on screen sizes (6.9"-) Run portrait and landscape orientations on screen sizes (7"+) How would I declare this without using androids deprecated (small, normal, large, xlarge) screen sizes?...

How To Make More Than Two buttons in Fragment to Open Different Activity

android,android-fragments,android-activity,android-fragmentactivity
I have Created 3 Activities and their class, i want to open them when button pressed, And buttons are in Fragment, i have successfully implemented this For A Single Button, and works. But I Want To do same thing for both button, How Can i make both button to open...

Android parentActivity not getting recreated after startActivityForResult returns

android,android-intent,android-fragments,android-activity
I have a MainActivity and inside it, I am loading a fragment A. From FragmentA , I am calling google placepicker activity using startActivityforResult as follows. PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); Intent intent = builder.build(getActivity()); getActivity().startActivityForResult(intent,PLACE_PICKER_REQUEST); But when I select place, onActivityResult(either in FragmentA or MainActivity) is not getting called....

How to land or navigate to previous activity if click on back button

java,android,android-activity,android-notifications
In My application i have implemented Notification. My Problem is if I click on received Notification it will redirect to the Activity which I have given there if I click on inbuilt Back button It will closing the application and going out. What I need is if I click on...

Android - App crashes on some devices at same line

android,android-activity,android-support-library,android-version
I published my Android app on Google Play and I get many reports about crashes from some devices. At first I thought that this is a SDK version problem, but after I update, it still happens. Here is the report log that I get: java.lang.NoSuchMethodError: android.view.Window.setStatusBarColor at stefanmaimon.milab.blenders.MainActivity.onCreate(MainActivity.java:81) at android.app.Activity.performCreate(Activity.java:5451)...

Starting new Activity not from the MainActivity file

android,android-intent,android-fragments,android-activity
I need to open new activity (using fragments if it's important) and I'm on a different file then the main activity so the code : Intent myIntent = new Intent(CurrentActivity.this, NextActivity.class); CurrentActivity.this.startActivity(myIntent); Is not good enough for me because I'm getting : ...is not an enclosing class ERROR referring :...

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
My Java Code and I know How To Play / Stop / Pause Video videoView=(VideoView)findViewById(R.id.videoView); // Video from raw Folder mediaController = new MediaController(this); uri = Uri.parse("android.resource://" + getPackageName() + "/"+ R.raw.abc); videoView.setVideoURI(uri); mediaController.setMediaPlayer(videoView); videoView.setMediaController(mediaController); videoView.requestFocus(); videoView.start(); ...

unable to add window token null is not for an application when using accessibility in android

android,android-activity,android-context,android-dialog
I am trying to create a transparent activity in front of another app's login page. MyAccessibilityService Class extend the AccessibilityService class. When login page is identified the tranparentActivity() function will be called to show the dialog box, but I will get the error like unable to add window token null...

Android variable never used [duplicate]

java,android,android-fragments,android-activity
This question already has an answer here: What does the “Assigned value is never used” warning mean? 5 answers After creating my activity, I get this warning: Variable 'station' is never used I not certain as to what that warning means nor how to fix it. I'm guessing the...

I want to extend Fragment and Activity in one class to use navigational drawer for an activity without changing my overall code

java,android,android-fragments,android-activity
This is my one of my fragment activity among three. All I want to do is use functions from Activity class(ie use setContentView(), startActivity()etc). Please don't worry about the package name of the project which I deleted for some reasons. Thanks in advance! import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import...

Making YesActionBar and NoActionBar theme in Android and using them in application

java,android,android-activity,android-actionbar
I would like to create simple activities in my android application and divide them into no-action bar and action-bar activities. To achieve this goal, I created 2 styles in styles.xml file: <style name="AppTheme" parent="Theme.AppCompat.Light"> </style> <style name="NoActionBar" parent="Theme.AppCompat.NoActionBar"> </style> Additionally, my android manifest contains following lines of code: <application android:allowBackup="true"...

Activtiy1 to Adaper to Activity2 ,and how to use the Activity1 data in Activtiy2

android,android-activity,android-adapter
I have two Activies, named Activtiy1 and Activity2, and one Adapter. Activity1 use the adapter, and in the adapter, I use intent to jump to Activiy2. My problem is that Activity2 wants to use the data from Activiy1, but I have no simple way to come through. I want a...

How to get the foregrund activity instance?

android,android-activity,reflection
I try to get the foreground activity for a long time, and i didn't managed to get it until now. I don't know if it even possible, but i am dont intersted in my app activity only. There is no data transfer between my service and the activity which i...

Is it possible to get an Activity object from other apps?

android,android-activity
I need to get the Activity from all the other installed apps on the device, possibly the launcher activity, but all of them is ok too. I know this code: Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.testapp.test"); that gives me an Intent object, but is there an equivalent to get an Activity object?...

Unable to start activity after click on android notification

java,android,android-activity,android-studio,notifications
I know, I am asking repeated question but I have tried everything and read every Q/A on SO. Still unable to start new activity when click on notification. I am using NotificationCompat. Below is my main activity package notification.test.example.com.notificationtest; import android.app.Activity; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import...

AppCompatActivity with normal fragments and support fragments

android,android-fragments,android-activity
I am using the latest AppCompatActivity (android.support.v7.app) and in the MainActivity, I am using the normal Fragment(android.app.Fragment) and getFragmentManager(instead of getSupportFragmentManager). Anyone aware of any problems if we mix Fragments from support library? I am facing some weird behavior in my application as posted in below question? Android parentActivity not...

SigninActivity is not an enclosing class

java,android,class,android-intent,android-activity
I'm trying to change the activity on "onPostExecute" but it doesn't seem to work even though it works on other activities. Here's my code: public class SigninActivity extends AsyncTask<String,Void,String>{ private TextView statusField,roleField; private Context context; private int byGetOrPost = 0; public SigninActivity(Context context,TextView statusField,TextView roleField,int flag) { this.context = context;...

Android-activities continue to use RAM memory even if they are left

android,memory,android-activity,android-studio,ram
For several months I am creating an application for Android and I have a problem I can not solve : my application unexpectedly crashes after a few minutes of use. Thanks to the " Memory Monitor " of Android Studio, I can see that my application is using more and...

Android Resources Not Found Exception

java,android,android-activity
Does the following error indicate that the Resource is not available from the Java Source? I verified the R file includes the Resource ID listed below: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0b0015 at android.content.res.Resources.getValue(Resources.java:2009) at android.content.res.Resources.getColor(Resources.java:1691) at com.flatbutton.FButton.init(FButton.java:97) at com.flatbutton.FButton.<init>(FButton.java:47)             at...

Does a recreated activity remember the original intent started it?

android,android-activity,recreate
While checking the documentation about using onSaveInstanceState, a question popped up. Let's say I'm using an app with several activities and now I'm in a specific activity that got started by a previous one. The current activity accepts extra values from the previous one. If I get a phone call...

Adding Icons to Navigation Drawer

android,android-fragments,android-activity
I am trying to add Icons to my NavigationDrawer. strings.xml <string-array name="nav_drawer_icons"> <item>@drawable/ic_action</item> </string-array> FragmentDrawer.java private static Integer[] icons = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // drawer labels icons = getActivity().getResources().getIntArray(R.array.nav_drawer_icons); } In my code above, I'm trying to load the xml's array to icons' array, but...

Android - My service onunbind but no bind again

android,android-activity,android-service,android-service-binding
I'm stuck in a problem with a service binding that is giving me nuts. I got an activity that is binding a service, and is frequent that the user go in and out of that activity. The problem comes when the user goes out first time of the activity this...

Add ActionBar to a PreferenceActivity

java,android,android-activity,android-actionbar,android-preferences
I am trying to make a Settings Activity using a PreferenceActivity. The problem is that the ActionBar won't show up no matter what I do. I've tried getSupportActionBar, getActionBar, setActionBar. Nothing works. I see other apps settings with ActionBars. Do they not use PreferenceActivity?...

ListView OnItemClickListener with a new Activity

android,listview,android-activity,onitemclicklistener,sqliteopenhelper
I have the first activity with this code: lvlitems.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //Toast.makeText(BuscarNota.this, "Clicked"+ id, Toast.LENGTH_SHORT).show(); Intent intent= new Intent(); intent.setClass(BuscarNota.this, Mostrar.class); intent.putExtra("id_nota", id); startActivityForResult(intent, 0); } }); And then I have the second activity with this code: EditText...

Navigation Drawer in multiple activities does not work

android,android-layout,android-activity,navigation-drawer
I'm trying to use NavigationDrawer on my activity (Home), but the content of activity is not shown. home_activity.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/home_activity"> <Button android:id="@+id/like_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="likeCounter"...

List view not returning to original state after clearing search

java,android,xml,android-activity,android-listfragment
I'm trying to get my list to show all my items again whenever I cancel a search from my search view but for some strange reason, the list gets stuck with the results only from the previous search. Does anyone know what is wrong with my code and how to...

Using USB-Intent filter for multiple activities

android,android-fragments,android-activity,intentfilter,android-permissions
I currently have two activites. One is a login activity that after successful login leads to a main activity that contains multiple fragments. I currently have a USB intent filter and broadcast receiver that checks to see if a USB device is plugged in. Once it detects it a device...

Bring activity in front on receiving Broadcast signal from another class

class,android-activity,broadcastreceiver
I have main activity that just registers the broadcast receiver for ACTION_USER_RESENT. I have written the code for receiving the broadcast signal in another class as follows. public class ReceiverScreen extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub if(intent.getAction().equals(Intent.ACTION_USER_PRESENT)) { //? } }...

Android crash in AsyncTask

java,android,android-activity,android-asynctask,progressdialog
When I run my projent and it's run AsyncTask from the activity that shows all content of the item the APP crash showing the follow error message: 06-17 20:56:52.856 418-428/? E/art﹕ Failed sending reply to debugger: Broken pipe 06-17 20:57:07.391 418-767/com.example.user.project_test E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #3 Process: com.example.user.project_test, PID: 418...

Change PendingIntent action at run time when click on notification

android,android-activity,push-notification,android-pendingintent
Why Downvote? Its a valid question not duplicate also and i have searched on it before asking I have integrated Push Notification in the app, i am working on rite now, what i am doing is setting the pendingintent to currentTopActivity class of the app if the app is...

Keep some variables initialized on destroy()

android,android-activity
I have an app that requires fairly substantial initialization (CPU-wise, not memory). When the user hits the back button, I'd prefer to leave the hard computations and allocated structures intact so there is no 3-4 second delay every time they hit the icon. What is the proper way to do...

android log's time-stamp addition

android,android-activity,kernel
while looking in android logging frame work - I checked /dev/log/main |system |event log files. in these log file I dont see time stamp. but at the same time "logcat -v time" display time stamp along with log. I check Logcat code Its reading androidlog_entry from /dev/log/* buffers and displaying...

Resuming Activities in Android Studio

android,android-activity,menu
I have an Android app that basically has 3 activities: game menu, showcase of data, and the game itself. When you complete the game the app is supposed to send you to the game menu. From what I understand this Activity is already running in the background, in order to...

Android: Time Loop in milliseconds

android,android-activity,time
This game is similar to one of those where your try to survive for as long as possible, like those hell-shooter games. So basically I wish to record to amount of time the user can survive after pressing "start". Similarly, I would like to continue to update the frames at...