FAQ Database Discussion Community


I try to use baseAdapter to create a listView ,but it doesn't work

android
I found a example in net,and imitate the example.The example can correct running,but i can't see the listView in contentView.below is my code activity_main.xml <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"...

Is there any sdk to log exceptions, events and errors in production app?

android,logging,error-handling,sdk,production
I want to catch all the un expected/undesirable events in my app during production. I want something which can send a error log file to server and I can easily read it through a web application. Do you know anything of this sort ?

Android Implicit Intent for Viewing a Video File

java,android,android-intent,uri,avd
In my Android app, I have a button that when clicked, launches the external application of my choice to play a video (I gather that this is called an "implicit intent"). Here is the relevant Java code from my onCreate method. Button button = (Button) findViewById(R.id.button); button.setOnClickListener ( new Button.OnClickListener()...

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

adapter.notifyDataSetChanged() not working when I update ArrayList

android,android-listview
I have seen a lot of post about this case but I don't find a solution for me. I use SwipeRefreshLayout.OnRefreshListener and this is my code in onRefresh() method. This doesn't work. new Handler().postDelayed(new Runnable() { @Override public void run() { Aviso aviso = new Aviso(); aviso.setTitle("MMMMMMMMMMMMMMMMMMMMMM"); aviso.setDescription("Deskribapena"); aviso.setPubDate("Wed, 19...

AndroidAnnotations and EventBus

android,android-annotations,greenrobot-eventbus
I have an annotated Activity in a library, which is a subscriber to an EventBus event from the same library. It looks something like this, greatly simplified: @EActivity(resName = "activity_foo") public class Foo extends Activity { public void onEvent(BarEvent event){ doSomething(); } } It should work according to this: http://timnew.me/blog/2014/09/14/otto-and-android-annotations-compatibility-issue-analysis/...

Synchronize local SQLite database with central database

android,performance,sqlite,compare
We are developing an Android App based on a product that already has a website. As a result, when launching the Android app it may happen that a lot of things differ between the local SQLite database and our central database. What is the fastest way to synchronize the Android...

Close module in android studio

android,eclipse,android-studio
in eclipse there is simple option to close or open project. How can I do it in android studio to close and open module without import it and delete each time?

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

Robolectric 3 : Load test specific resource

android,unit-testing,robolectric
I'm using Robolectric 3 and I'm trying to load some resources that are in my test/res/ folder. Here is my file hierarchy : project/ |-src/ |--main/ |---AndroidManifest.xml |---res/ |----raw/ |-----prod.json |--test/ |---java/ |----com.app/ |-----CustomTestRunner.java |-----Mytest.java |---res/ |----raw/ |-----test.json I would like in MyTest.java to do something like RuntimeEnvironment.application.getResources().openRawResource(R.raw.test); but i...

how to save hashmap of objects to shared preferences

android,hashmap,sharedpreferences
I have a hashmap of objects.I want to save that to shared preferences and get it. How can I do this?

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

How to put a layout below other layout in Android

android,layout
I have this code: RelativeLayout frame = new RelativeLayout(activity); RelativeLayout layout = new RelativeLayout(this); RelativeLayout.LayoutParams dateArea = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, 90); dateArea.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics(); int height = displayMetrics.heightPixels; RelativeLayout mapLayout = new RelativeLayout(this); RelativeLayout.LayoutParams mapParam = new RelativeLayout.LayoutParams(...

mobile friendly CSS multi column layout that doesn't suck like flex

android,html,css,flex
I implemented a flex multi column layout, got it to look great on my desktop, then looked at it on a mobile device and it was complete trash (all scruntched together, ignoring width parameters completely). Played with it for hours and everywhere I went on the internet said flex sucked...

Add a ListView or RecyclerView to new NavigationView

android,listview,recyclerview,navigationview
I am using the new NavigationView from revision 22.2.0 of the support library by Google. It works perfectly fine to generate a navigation drawer populated using a menu res. I was wondering is it possible to add a ListView or RecyclerView to the navigation drawer so that it can be...

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

Floating Action Button in Xamarin.Forms

android,xamarin,monodroid,xamarin.forms,floating-action-button
I had completed my App's home page in Xamarin.Forms Portable. Now i want to add a Flotation Action Button In my Android Project ! Is there any way to add FAB for Android in my existing home page, which was coded in Xamarin.Forms Portable. OR I want to create a...

Unfortunately, (My app) has stopped. Eclipse Android [duplicate]

java,android,eclipse,adt
This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers I'm a beginner in android developing and I'm trying to build a simple app but I'm getting this error in the emulator.(Unfortunately,(App) has unexpectedly stopped). LogCat http://i.stack.imgur.com/VZhuL.png package...

How to make image distributed to screen width in RelativeLayout?

android,android-layout,relativelayout,android-relativelayout
I have three icon the a RelativeLayout, how to make them distributed to screen width? Since I may add more icon to this line programmatically, I cannot hard code a fixed margin to these icon. <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/icon1" android:src="@mipmap/icon" /> <ImageView android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/icon2" android:layout_toRightOf="@id/icon1"...

Android Studio and gradle

android,android-studio,gradle
I tried importing Xabber ( GitHub ) within Android Studio , I did the git init etc . Now I find that I can start the app for that problem Gradle , I've looked everywhere , but could not find anything that would work .. The problem is: Error:Execution failed...

Android set clickable text to go one fragment to another fragment

java,android,android-fragments,spannablestring
I need to do something like this. Suppose I have 2 fragments A and B.There is a text which can be clickable in fragment A and when user click this text , he can go to fragment B. This example helped me to do it but I think it does...

Why i can not use arabic character in hello chart library in android studio?

android
I use the hello chart library in my android project and i want use arabic character in chart,but when write this code: axisX.setName("تجزیه و تحلیل"); i can not see a any character in my chart,what happen?...

How to use Library from GitHub in android App

android,github,gradle,libraries
I downloaded this library to use in my app, however, I can't get Android Studio to do the gradle build now. Anytime I try, I get "error:configuration with name 'default' not found". I've tried several other StackOverflow answers, but I still can't compile. My dependencies (from build.gradle Module: app) dependencies...

Execute command if view exists

android,robotium
I'm using robotium to write tests for our android application. I'm looking to execute a command if a certain view or text exists. It would be ideal to check if the view/button exists, but I'm open to checking if the logout text exists as well My (incorrect) pseudocode would be...

Beginner:What do several parts of my code mean? [on hold]

java,android,button
Because I'm an absolute beginner I have a really simple question but I can't help myself.Maybe they are too simple because I can't find the answer in forums, books or other internet paged. I do not get the meaning of some parts of my java code because i just knew...

Where are the local variables of an Android app stored?

android,variables,local
The Dalvik Virtual Machine (DVM) has a register-based architecture, as opposed to the Java Virtual Machine (JVM) which is stack-based. So I assume that the local variables of an Android app are stored in the registers. Am I correct? If not, please correct me. If yes, what kind of memory...

Dagger 2 Custom Scope for each Fragment

android,android-fragments,dagger-2
I'm a little confused about how to best use the custom scoping in Dagger 2. I've looked at a couple different articles which seem to suggest two different ways of doing it: MVP Presenters that Survive Configuration Changes Part-2 (Github repo): Uses unique custom scopes for each fragment, e.g. @Hello1Scope...

No such table found even though app successfully opens database from assets folder

java,android,sqlite,android-sqlite,sqliteopenhelper
I'm new to android development. I'm trying to use a pre-populated database whoch is stored in my assets folder. Log shows that the database gets opened but 'NO SUCH TABLE ERROR' is shown.I can't find any solution to this error. Please help. MyDatabase.java : package com.example.android.atlas; import android.content.Context; import android.database.Cursor;...

Update the ListView after renaming a ListView item within a Popup Menu in a BaseAdapter in Android

android,listview,android-listview,android-arrayadapter,popupmenu
I have a ListView which has a custom Adapter and a PopupMenu giving some options on the list item, including a rename option. After renaming the list item I want to refresh the ListView and display the renamed list item also. Following is my code. DocumentsFragment public class DocumentsFragment extends...

setOnClickListener error Null object

java,android
I saw many questions like mine and I try to fix my codes but failed... this is my code: public class MainActivity extends ActionBarActivity { EditText usernameEditText; EditText passwordEditText; public Button saveme; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); usernameEditText = (EditText) findViewById(R.id.username); passwordEditText = (EditText) findViewById(R.id.pass); saveme = (Button)...

Why i get can not resolve method error in class android?

android,json
I use this tutorial: JSON and part of code to this: protected String doInBackground(String... urls) { TextView lbl=(TextView) findViewById(R.id.provCODE); person = new Person(); person.setName(lbl.getText().toString()); //person.setCountry("1853"); //person.setTwitter("1892"); return POST(urls[0],person); } but in the this line: person.setName(lbl.getText().toString()); i get this error: Can not resolve method. How can i solve that?what happen? my...

Android SQLite: Fast insert/update

java,android,sqlite
In my Android application I am using compiled statements to be able to insert rows quickly: insert = db.compileStatement( "INSERT INTO foo (id, aaa, bbb, ccc) " + "VALUES (?,?,?,?)"); This works correctly and quite fast. However when there is already foo with id, I am receiving following exception: column...

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

android,button,android-intent,share
I intend to share 6 text information, however it always shows the last information only, i.e. share.putExtra(Intent.EXTRA_TEXT, Contact); I also tried to use a string array to store all 6 information, i.e: share.putExtra(Intent.EXTRA_TEXT, stringArray); However, it still doesn't work. Can anyone help ? Thank you. My code: public class SingleJobActivity...

Get current playing track info from all the available android devices

android,android-mediaplayer,music
I m welling to get current playing track info from all the available android devices.Therefore i have tried out this code and it works fine in the emulator or with any nexus phone but as soon as i tried it out on an xperia phone it doens work and it...

Now that SSLSocketFactory is deprecated on Android, what would be the best way to handle Client Certificate Authentication?

android,ssl,okhttp,pkcs#12
I am working on an Android app that requires Client Certificate Authentication (with PKCS 12 files). Following the deprecation of all that's apache.http.*, we have started a pretty big work of refactoring on our network layer, and we have decided to go with OkHttp as a replacement, and so far...

Action view intent does not work

android,search-suggestion,custom-search-provider
Action view Intent for Search widget does not send Intent i am using Toast to show whether intent is sent when user choose item from suggestion in Quick Search Box here is snippet where intent is received in searchable Activity if (Intent.ACTION_VIEW.equals(intent.getAction())){ /* Intent countryIntent = new Intent(this, RecordActivity.class); countryIntent.setData(intent.getData());...

Broken pipe error when executing Android method more than once?

java,android,illegalstateexception,broken-pipe
I'm trying to execute the following method to spoof the MAC address of an android device. The method runs every time the user clicks a button: public void changeMac(View v) throws IOException { editText = (EditText)findViewById(R.id.newMacText); String mac = editText.getText().toString(); Log.d("my log", "" + mac); String[] cmds = {"ip link...

Android popup like IOS

android,view,popup
I need to implement popup dialog like in iOS, and show above some view (map point in this case), but don't know how to implement it. Screenshot attached. Will be glad any proposals.

findViewById returns null when try to find TextView in getView [on hold]

android,android-layout,listview,android-adapter
I don't know but findBtView method cannot fint view and get null all the time. Here are my files: http://pastebin.com/0gJPH8mi

Problems implementing ViewHolder pattern

android,design-patterns
I'm working on an android app from a book. I'm getting errors : "crimeHolder cannot be resolved" and I can't understand why.. public View getView(int poisition, View convertView , ViewGroup parent) { //If we weren't given a view, inflate one if (convertView == null) { convertView = getActivity().getLayoutInflater().inflate(R.layout.list_item_crime, null); ViewHolder...

Fixed element in android?

android,xml,android-fragments
I am using a FAB(Floating action button) and a ViewPager that has a list inside a fragment. The ViewPager stops due to the FAB block and each are blocks the ViewPager being on top of the FAB activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:fitsSystemWindows="true">...

Android Studio: cannot upgrade google play services

android,google-maps,android-studio,google-play-services,google-play-developer-api
I have tried download the latest version on the sdk manager, but is still not working. I have seen other posts telling users to enter the following... compile 'com.google.android.gms:play-services:4.2.+' I do not understand where to enter it. I tried in the terminal feature of the android studio but it gives...

Frequent usage of asynctask

android,android-asynctask
I have created an AsyncTsak class in my project which downloads some information from web server. I am sure that it works well because when it is called by onCreate() , I can see the result . But unfortunately when I call it again via a button it doesn't work....

custom arraylist get distinct

java,android
is there any way to get the distinct values of a custom arraylist? public class mystatistic extends BaseActivity { public String objectid; public String playerid; public String playername; public String enemyid; public String enemyname; public String question; public mystatistik(String objectid, String playerid, String playername, String enemyid, String enemyname, String question)...

Have a fragment re-load on post execute

android,android-fragments,android-asynctask
I have a fragment which calls an async task. When the async task is done I want the fragment to completely re-load. Basically, my fragment loads a random review. The user then rates the review with a star bar at the bottom. When they click the star bar a async...

Notification whenever a new topic is created on mosquitto

android,mqtt,mosquitto,libmosquitto
I am trying to implement Push notifications on Android, using Mosquitto broker. So, different android application create topics based on tehir id on which they will receive notifications. To send notifications to those android applications we need the name of the topic. I am wondering if there is a way...

Error:(12) No resource identifier found for attribute 'scalteType' in package 'android'

android,android-studio
Getting error messages when running an app on debug mode during the Gradle Build in Android Studio. This is the error message: Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig...

I have a MapsActivity and I need to link that to an ActivityBarFragment

java,android
Ok, so I'm kinda trying to develop an app with Android Studio, I'm actually a PHP dev and I'm trying to learn Java. Enough about me, I have a little diagram that'll explain better what I want to do! But, I'll explain it here anyways. I have a MapsActivity and...

Is there any way to use a pre-existing database from Xamarin without copying it from Assets?

android,xamarin,xamarin.forms
I have a rather large SQLite database (~20 mb) I need to access from my Android Xamarin-Forms app. Everything online I've read says you can read the database by copying it to the filesystem first. For example, this question. However, won't that mean the large database is duplicated, wasting users'...

android imageView scale

android,imageview,scale
I have an ImageView which is populated from database (the image comes from database). in the database i have images both portrait and landscape!! how can i adjust the imageView to scale it self according to the image width and height. I have tried many ways but no result! any...

Adding a fragment to android.R.id.content enables clicks on background fragment

android,android-fragments
I've and Android Application. I want to display a fragment in the bottom of the screen on top of everything (like a dialog, but in the bottom). I'm adding a fragment to android.R.id.content: FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction(); transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); transaction.add(android.R.id.content, new MyFragment()).addToBackStack(null).commit(); The fragment is displayed, but the views that are...

android - service for interaction with wearable

android,android-service,android-wear,google-api-client,android-wear-data-api
I tried creating a service (which extends WearableListenerService) which should send as well as receive data with wearable. But when i created GoogleApiClient object in that service, it failed with NullPointerException. public class MyService extends WearableListenerService{ private GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .build(); private final String MESSAGE_PATH = "/message";...

Hide Toolbar with CoordinationLayout and Webview not working

android,webview,toolbar
I'm trying to hide the Toolbar when scrolling the WebView, with the new CordinationLayout, but it's not working. Is there any way to do it? This is my xml: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.themobilebakery.isus.gui.WebViewActivity"> <WebView...

How to set speaker phone off when the app is killed by the “Recent App drawer”

android,android-audiomanager,ondestroy
I implemented an app which has a button speaker, which is manually set "on" by myAudioManager.setSpeakerphoneOn(true) and "off" vice-versa. But the bug is when you close the application while the speaker is on, it forgets the speaker was on. The next time, the speaker remains on and the call is...

why is Android app publishing taking several days [on hold]

android,google-play,publishing
I have uploaded my app on the store 3 days ago and it status still : PENDING PUBLICATION I have uploaded all the app listing needed : description, screen shots ... and google didn't contact me on E-mail. does anyone had the same case before ???...

Prevent certain views from being animated with android:animateLayoutChanges=“true”

android
I have a horizontal linear layout that has 3 views. An open and close button and a text view. On load the close button is set to setVisibility(View.GONE); So it is only showing one imageview, open, and a textview with some text. I am also using android:animateLayoutChanges="true" On my parent...

Get current latitude and longitude android

java,android,gps,geolocation,location
Requirement: 1.Sometimes(not everytime) I am getting latitude and longitude 0.0. 2.I want to know how to get the location update after user has enabled the gps from the settings. Here is my code public class GPSTracker extends Service implements LocationListener { private final Context mContext; // flag for GPS status...

XMLPullParser black diamond question marks with certain characters

android,xml,character-encoding,xmlpullparser,questionmark
I'm making an android app, that needs to fetch and parse XML. The class for that was made following the instructions from here http://www.tutorialspoint.com/android/android_rss_reader.htm and the fetcher method looks like this: public void fetchXML() { Thread thread = new Thread(new Runnable() { @Override public void run() { try { URL...

Set value for Spinner with custom Adapter in Android

android,dynamic,android-arrayadapter,android-spinner
I am developing a android application with spinner in a form. The spinner items and spinner values are different. I want to collect all the value from the from including spinner and set a rest api service to web back end. here is the response array. {"Status":true,"errorType":null,"countryList":[{"Code":"US","Name":"United States"},{"Code":"CA","Name":"Canada"},{"Code":"AU","Name":"Australia"},{"Code":"GB","Name":"United Kingdom"}]} I...

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

android,android-intent,bluetooth,android-bluetooth,bluetooth-oob
I have prepared a simple test project for this question at GitHub. I am trying to create an Android app, which would scan a QR code from a computer screen and then use the data (MAC address and PIN or hash) for easy pairing (bonding) with a Bluetooth device. Similar...

Is possible to save Realm documentation for offline reading?

android,ios,documentation,realm
I'm going to vacations this Saturday and I need to have Realm API documentation available for offline reading (https://realm.io/docs/swift/latest/api/index.html). Does it exist somewhere for download? Thanks

How to restrict file copying shared using Content Provider in Android?

android,security
Is it possible to forbid making copies of files for third party applications (like adobe reader), that I am using to open pdf files stored in internal memory of my application?

Android RecyclerView with Fragments

android,android-viewpager,recyclerview,fragmentpageradapter
I have a ViewPager with a FragmentPagerAdapter. My customer wants me to switch from ViewPager to list; a vertical list with all the fragments. There can be a lot of fragments, so adding them all in a ScrollView is out of the question. Can I somehow do this while still...

Android custom calendar view disable specific dates

android,calendarview
i'm new to android developing and started to develop an booking app. There is a calendar view and i want to disable booked dates in that calendar. I found out that disabling feature is not there in android default calendar. so could you please help me to find a good...

Android String if-statement

java,android,string
I have a if-statement in the start of my app if (ready.equals("yes")){ ... } and later on my code I have ready="yes"; but the if statement is never called, why? The ready="yes"; is called from a background thread, is that why? public void DownloadFromUrl(final String fileName) { //this is the...

AdMob load ad failure

android,admob
Ok the problem is solved without doing anything. I used the following guide: https://developers.google.com/admob/android/quick-start. and it didn't work so instead,, I used .addTestDevice in onCreate(). However, ads (requesting banner) still fail to load AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .addTestDevice("The Correct Code extracted from logcat") .build();...

Multiple dex files , finished with non-zero exit value 2

android
MY LOGCAT DESCRIPTION : UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at...

Crop does not work for gallery images

android,image,crop
I am using the following code to crop images from camera and gallery : private void doCrop() { final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Toast.makeText(this, getApplicationContext().getString(R.string.crop_unavailable), Toast.LENGTH_SHORT).show(); // return }...

How to Parse sync data between devices?

android,parse.com
Is it possible to make for example a chat app using parse, in a way that when 1 device sends a message to the other device, the other device will recieve it instantly, without using any timer. Which means Parse will somehow send the other device the message when it...

ValueAnimator translate animiation

java,android
I need to create a translate animation through ValueAnimator to some specific x and y value, so I wrote the following code but its not work as I expected and throws NullPointerExceptions on valueAnimator.getAnimatedValue("x") and valueAnimator.getAnimatedValue("y")! ValueAnimator translate = ValueAnimator.ofInt(viewX, endX, viewY, endY); translate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator...

Paid and Free versions of android app

android,gradle,android-version
I am wondering what is the best way to have two different versions of an android app. I would like to have version of my app with ads and one without ads (the paid one). What is the easiest way to achieve this ? I have found something called version...

Contexts and callbacks from asynchronous tasks

android,android-fragments,asynchronous
I've been experiencing this problem on some devices, especially Samsung. I have an activity that has 7 fragments. In most of them, I start an async task for getting some data. I handle the exceptions by creating a handler in onCreateView(). handler = new Handler(new Handler.Callback() { @Override public boolean...

Android Espresso: Test running failed. No test results Empty test suite. Why?

android,android-espresso
Can't make my Espresso UI test work. Where's the problem? What result should I get for this simple app to consider that it's working? I have "android.support.test.runner.AndroidJUnitRunner" for Instrumentation runner in Edit Confirurations. From AndroidManifest.xml: <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" android:targetPackage="my.package"/> From build.gradle: defaultConfig { applicationId "my.package" minSdkVersion 18 targetSdkVersion 22 versionCode 1...

getView method causing NullPointerException

java,android,android-studio
I'm getting a NullPointerException, when I'm trying to get some image from database I think my getter and setter method is wrong, any help is much appreciated. This is my Activity public class ViewMoreDetailsImages extends Activity{ ProgressBar progressbar_01; ListView lv_images; ImageAdapter imageAdapter; List<ImageInformation> imageInformationList = new ArrayList<ImageInformation>(); @Override protected void...

Passing dynamic string resource to “setText()”

android
I am trying to make a dynamic string and converting a hardcoded string which has been passed to setText() function . However it doesn't seem to accept it . Here is what I have tried : Original code : device.name.setText("Mac :" + data.macAddress); Strings.xml declaration : <string name="mac">Mac :</string> New...

mapFragment.getMapAsync(this) - NullPointerException

android,google-maps,android-maps-v2
I am using com.google.android.gms:play-services-maps:7.5.0 version of Google Maps services. When trying to call the below I get java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager()...

Blank screen on GridView

android,arrays,gridview
I'm trying to create a GridView with an array of strings. These are XML, and MainActivity and Adapter, but what I get is a blank screen. I'm change the background, but the result is the same, but clicking on a point on the screen appears to me the toast stating...

Android listview dont refrsh by BroadcastReceiver

android,listview
in my application I'm trying to retreive data from server by service and sending to broadcast after finish receive and save in database. I'm defined simple broadcast in fragment to listen to that to get again data from database and update list view private BroadcastReceiver getContactsList = new BroadcastReceiver() {...

update textview title in an Activity from a service

android,service,android-textview
i have an homeActivity which contains a webview with an actionbar, the title of the actionbar is an textview public static TextView mTitleTextView; and also has an class which do receive gcm message public class GCMNotificationIntentService extends IntentService { after the app received a message i want to put the...

FileNotFoundException when writing to raw file

java,android
I'm trying to write in file "numbers.txt". It's located in raw folder. I'm using this function to write in file: public void writeToFile(String data) { try { Uri url = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.numbers); String Path = url.toString(); File f = new File(Path); OutputStreamWriter outputStreamWriter = new...

getBoolean returning false

java,android
I'm writing a program that needs to check for default preference settings and respond accordingly. The getBoolean method is always returning false even though R.xml.preferences has defaultValues set as true. I've tested preferences.contains(prefKey) and this has returned true. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fullscreen); PreferenceManager.setDefaultValues(this, R.xml.preferences, true); populate();...

Spinner height expands to bottom of screen

android,android-layout,android-fragments
I have a fragment with a spinner in a layout. The spinner xml is: <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/spCategory" android:spinnerMode="dialog" android:dropDownWidth="match_parent" android:prompt="@string/label_category_select" /> Populating the spinner is done like this: List<Category> categories = categoryRepository.getAll(); CategoryAdapter adapter = new CategoryAdapter(this.getActivity(), categories);...

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

Action Bar activity is closed

android,android-actionbar
What is wrong with my code? When I run application on my device/emulator my application is crashed " Unfortunately! Action Bar has stopped" public class Main extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ActionBar mActionBar = getActionBar(); assert mActionBar != null; mActionBar.setDisplayShowHomeEnabled(false); mActionBar.setDisplayShowTitleEnabled(false); LayoutInflater mInflater =...

Can't migrating AndroidManifest.xml file to Android Studio?

android,android-studio
When i try to migrating Eclipse ADT project to Android Studio using "Import project (Eclipse ADT, Gradle, etc.)" then selecting project root folder and then third window gives me error like this C:\Users\Tsomone\workspace\cims-android-app-new\AndroidManifest.xml: Invalid XML file: C:\Users\Tsomone\workspace\cims-android-app-new\AndroidManifest.xml: Premature end of file. and when i try to click Finish, it shows...

Can I install 2 or more Android SDK when using Eclipse

java,android,eclipse,sdk,versions
I am new to android developments. I am setting up my android development environment using Eclipse. I have a test smart phone with Android version 4.2.2. The automatic installation installed the latest Android SDK version, which is 5.1.1. My questions are: 1. Do I have to install the SDK version...

BitmapFont class does not have getBound(String) method

java,android,libgdx
Previously I used getBound method for BitmapFont class in libgdx, but now, I am unable to use it. I cannot find the changes in latest version. Any help is appreciated. Thank you...

Get element starting with letter from List

java,android,list,indexof
I have a list and I want to get the position of the string which starts with specific letter. I am trying this code, but it isn't working. List<String> sp = Arrays.asList(splited); int i2 = sp.indexOf("^w.*$"); ...

Java- HashMap.get returns null when it shouldn't

java,android,null,hashmap
I am using a HashMap to link some strings to integers, which are then used to index a list. The strings I am using in .get() are passed to a method, from an android spinner, and are definitely correct as I outputted them to the log, and they match those...

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

error: cannot find symbol class AsyncCallWS Android

java,android,web-services
I'm trying to rewrite the application in this, in Android Studio link, which is written in Eclipse. There are two problems, first problem is there is this line in the project : import com.example.webserviceactivity.R; I couldn't write this one on Android Studio. The second problem is, in this part of...

how does android ImageView resize my image?

android
I have some 100*100 icons and I cannot find better resolution icons so I put them inside drawable folder. The width and height of the image view are set to wrap_content. When the image is shown on a xhdpi screen will the image be scaled to 200*200 automatically? or should...

Twitter4j - cannot resolve method - setUsessl(boolean)

android,android-studio,twitter4j
I'm using twitter4j 4.0.3 core I have this code: public final class TwitterUtil { private RequestToken requestToken = null; private TwitterFactory twitterFactory = null; private Twitter twitter; private TwitterUtil() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(ConstantValues.TWITTER_CONSUMER_KEY); configurationBuilder.setOAuthConsumerSecret(ConstantValues.TWITTER_CONSUMER_SECRET); configurationBuilder.setUseSSL(true); Configuration configuration =...

echo json_encode after mysql_query failure

php,android
I'm currently trying to develop an Android app that communicates with a database. I use php scripts to communicate between my app and the database. For error handling purposes, I was wondering if I could replace the die() function in php with something simliar to json_encode so that I can...

How to cancel alarm in android after deleting a item in Sqlite database

android,sqlite
I have a visit reminder activity where I am getting info like name, date, time and reminds before time. After button click I am saving this info in local sqlite database. In the save button click, I am getting every info and then set alarm for generating notification. I also...

Facebook Android API asks for additional permission

android,facebook,facebook-graph-api
I am using v2.3 api here I can login with Facebook login button. Now how can I call additional permission on click? I have looked through answers for this question, but all of them look to be back-dated. Can someone show me the right way of asking for addition permission...

How do i get information from textview?

android,textview
Ii am trying to figure out how to get the information that a user entered into a textview box which contains userpassword and username. My goal is to display the information from the two fields when the user clicks the button Login. I am stuck trying to display the information....

Android programming, draw a rectangle with specific coordinates

android
I am new to android programming. I am trying to draw a rectangle as in the image below. I have no idea how to do it with Rect(int left, int top, int right, int bottom). Can someone help me with this thanks. ...

Getting particular view from expandable listview

java,android,listview,android-fragments,expandablelistview
In my list view I have an textview in expandable group and I want to open the dialog when textview is clicked to fill the information through edittext and update textview. Problem: how could I get the groupview textview item in my fragment oncreateview() method....

Cant start developing for android

android,android-studio
I have an app on iOS and now i need an android version. BUT I CANT. I downloaded android studio, downloaded everything from SDK manager, did everything for a basic project. But... Everything i use is deprecated. Tried making tabbed application... ActionBarActivity deprecated, every other thing i trie is deprecated......