java,android,android-layout,admob,forcecloseRelated issues-Collection of common programming errors


  • Daniel Dinnyes
    java parsing date formatting simpledateformat
    I have encountered a very weird behavior while using SimpleDateFormat for parsing a string to a date. Consider the following unit test:@Test public void testParse() throws ParseException {DateFormat dateFormat = new SimpleDateFormat(“yyyyMMdd”);String dateStr = “2012-12-21”;Date parsedDate = dateFormat.parse(dateStr);Calendar date = Calendar.getInstance();date.setTime(parsedDate);Assert.assertEquals(2012, date.get(Calendar.YEAR));Assert.assertEquals(11, date.get(Calendar.MONTH)); // yeah, Calend

  • Rohit Jain
    java regex string split
    I’m making a text based dice roller. It takes in strings like “2d10+5” and returns a string as a result of the roll(s). My problem is showing up in the tokenizer that splits the string into useful parts for me to parse into information.String[] tokens = message.split(“(?=[dk\\+\\-])”); This is yielding strange, unexpected results. I don’t know exactly what is causing them. It could be the regex, my misunderstanding, or Java just being Java. Here’s what’s happening: 3d6+4 yields the string array

  • Em Ae
    java httpclient
    I have a webservice which is accepting a POST method with XML. It is working fine then at some random occasion, it fails to communicate to the server throwing IOException with message The target server failed to respond. The subsequent calls work fine. It happens mostly, when i make some calls and then leave my application idle for like 10-15 min. the first call which i make after that returns this error. I tried couple of things … I setup the retry handler likeHttpRequestRetryHandler retryHan

  • isaiah
    java random
    I have seen posts which explains pretty much this question but they all used integer values and I honestly do not fully understand it hence this question:I am trying to generate random numbers from the range (-1554900.101) to (52952058699.3098) in java and I was wondering if anyone could explain this to me as I really want to understand it.My thoughts: will this be a right approach? 1) Generate a random integer number within my specified range 2) Divide the generated number by pi to get float/do

  • Pascal Thivent
    java spring maven-2 jersey
    im currently struggling to integrate a REST Service based on Jersey and Spring. I’m using Spring 3.0.2-RELEASE and jersey-spring 1.2.But jersey-spring adds a dependency to Spring 2.5.6 to my project which of cause conflicts with the 3.0.2-RELEASE to give me thefollwing error:11:58:25,409 ERROR org.springframework.web.context.ContextLoader:215 – Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path r

  • Yatendra Goel
    java oop constructor setter
    I know that private instance variables are accessed through their public getters and setters method.But when I generate constructors with the help of IDE, it initializes instance variables directly instead of initializing them through their setter methods.Q1. So should I change the IDE generated code for constructors to initialize those instance variables through their setter methods.Q2. If yes, then why IDE don’t generate constructors code in that way?============================= EDITED ======

  • talk to frank
    java junit
    I’m trying to implement unit testing for aproject, it uses a legacy “utility” project that is littered with static methods and many of the classes are final or their methods are final. I’m not able to update the legacy project at all.JMock and EasyMock both choke on final methods, and I don’t see a nice way to test the static calls. What techniques are there to test these?

  • tstenner
    java xml http scala soap
    I’m trying to write a program in Scala, that will accept SOAP-requests, get the response from the real server (or read it from the local disc) and return the data to the original client.I’m new to the java/scala ecosystem, so I have no clue, what libraries to choose. I heard Scala’s XML-handling is quite nice, so I don’t know, whether I should use some enterprisey soap-library/framework like jax-ws, jboss-ws, axis, cxf, xmlbeans, etc.Basically, I just needa library, that accepts the requests (cu

  • Agemen
    java jaxb
    I’m trying to process some XML files using the JAXB implementation shipped in Java 7. I’m using these versions :501 ~ % xjc -version xjc 2.2.4 502 ~ %java -version java version “1.7.0_01″ Java(TM) SE Runtime Environment (build 1.7.0_01-b08) Java HotSpot(TM) Server VM (build 21.1-b02, mixed mode)The problematic decalaration in the XML schema is the following :<xsd:complexType name=”CategorizeType”><xsd:complexContent><xsd:extension base=”se:FunctionType”><xsd:sequence

  • hennr
    java orm jpa
    What is the smartest way to get an entity with a field of type List persisted?Command.javapackage persistlistofstring;import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Persistence;@Entity public class Command implements Serializa

  • Amit Kotlovski
    android junit jar instrumentation
    I have some java code (compiles nicely for Android) in a library project (LIB) that I want to use in an another Android project (A).As LIB’s code is unlikely to change much, I opted for adding it as a jar to A. It works fine.I have another project that is an Android instrumentation project, testing the first Android project (B).So what we have now is A including LIB as an external jar, and B testing A.The problem starts when I want to access from B code written in LIB. From what I see, unless I

  • Bill the Lizard
    android android-emulator console
    The Console and LogCat printouts stopped working in Eclipse with the Android Emulator.I’m getting the following Exception in the Console[2011-11-10 11:04:58 – Unexpected error while launching logcat. Try reselecting the device.]device not foundcom.android.ddmlib.AdbCommandRejectedException: device not foundat com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)at com.android.ddmlib.Device.executeShellCommand(Device.jav

  • Joe
    android
    I’ve spent about 6 hours on this so far, and been hitting nothing but roadblocks. The general premise is that there is some row in a ListView (whether it’s generated by the adapter, or added as a header view) that contains an EditText widget and a Button. All I want to do is be able to use the jogball/arrows, to navigate the selector to individual items like normal, but when I get to a particular row — even if I have to explicitly identify the row — that has a focusable child, I want that ch

  • Carl Manaster
    android cursor wrapping android-contentprovider
    I’m creating ContentProvider which is a proxy of another ContentProvider (for security issues and to give access to part of functionality of full app). public class GFContactsProvider extends ContactsProvider implementsDatabaseConstants {private Context mContext;private ContentResolver mContentResolver;@Overridepublic boolean onCreate() {mContext = getContext();mContentResolver = mContext.getContentResolver();}@Overridepublic Cursor query(Uri uri, String[] projection, String selection,String[] s

  • WarrenFaith
    android android-listview
    I have used the pulltorefresh example of Johan Nilson.Its working excellent.But I need to apply inversely also.i.e pull Up to refresh.I applied all methods inversely but I couldnt get the solution.Pls give some ideas.I have posted my code also.public class PullToRefreshListView extends ListView implements OnScrollListener {private static final int TAP_TO_REFRESH = 1;private static final int PULL_TO_REFRESH = 2;private static final int RELEASE_TO_REFRESH = 3;private static final int REFRESHING =

  • Sabre
    android nine-patch
    I’m trying to customize ToggleButton in my app. I’m setting 9-patch image as background as written here. And then in my layout xml:<ToggleButtonandroid:id=”@+id/toggle”android:layout_width=”wrap_content”android:layout_height=”wrap_content”android:layout_gravity=”center_horizontal”android:background=”@drawable/btn_toggle_bg”android:checked=”true”android:gravity=”center_horizontal|center_vertical” />btn_toogle_bg.xml:<?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”

  • Andrei
    android eclipse phonegap cordova
    I am using the latest version of PhoneGap. I am using their code, modified only the App Name and when I run it on the emulator I am getting this error: “Unfortunatly phonegapExample has stopped”.My LogCat:12-07 00:04:48.573: I/Process(996): Sending signal. PID: 996 SIG: 9 12-07 00:04:51.814: W/Trace(1013): Unexpected value from nativeGetEnabledTags: 0 12-07 00:04:51.814: W/Trace(1013): Unexpected value from nativeGetEnabledTags: 0 12-07 00:04:51.814: W/Trace(1013): Unexpected value from nativeGe

  • ChrisF
    android eclipse maps
    I’m trying to follow this guide to get a simple map running: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzwI’m getting lost at steps 6 and 8. Where do I put the “GooglePlayServices.util…” line and the “GoogleMap map =” line?I put them both in the androidmanifest.xml file before the final . The program runs but it then crashes when I try to open it both in an emulator and on my android device.Here’s my code.Activity_Main.xml:<fragment xmlns:android=”http

  • user1400538
    android xml xml-parsing
    I try to parse xml from this sourceFollowing is my parsing code:while (eventType != XmlPullParser.END_DOCUMENT) {switch (eventType) {case XmlPullParser.START_TAG:if (parser.getName().equals(“Title”)) {current_tag = tag_title;deal = new Deals();}if (parser.getName().equals(“MSRP”)) {current_tag = tag_msrp;}if (parser.getName().equals(“ConvertedCurrentPrice”)) {current_tag = tag_convertedprice;}if (parser.getName().equals(“SavingsRate”)) {current_tag = tag_savings;}if (parser.getName().equals(“Sma

  • gcl1
    android amazon-web-services
    I just started using the Android SDK for AWS SDB, and am encountering an unexpected result doing writes and reads. This is surely a simple problem, so I would appreciate any explanations!Here’s the problem.First, I write a record to SDB like this:sdb.createDomain(new CreateDomainRequest(“myDomain”));List<ReplaceableAttribute> attributes = new ArrayList<ReplaceableAttribute>(1); attributes.add(new ReplaceableAttribute().withName(“myField”).withValue(myField));sdb.putAttributes(new Pu

  • kittu88
    android android-layout orientation xml-layout
    I have created a layout for an activity. The layout contains some image buttons and text views. The problem is that when I am setting the orientation of my device to portrait, its working fine, but when I am changing the orientation to landscape, the layout is giving unexpected results.Here is my layout file:<ScrollView xmlns:android=”http://schemas.android.com/apk/res/android”android:layout_width=”fill_parent”android:layout_height=”fill_parent”android:fillViewport=”true”android:padding=”50dp

  • oberthelot
    android android-layout android-widget android-ndk android-manifest
    I have this app (Only one activity) that use some android UI and some native C++ lib to do OpenGl drawing and calculation.It seems like the activity creates some “binder thread” on it’s own, and I’m pretty sure it causes some corruption amongs my native calls.What are the binder threads ? Can they be removed or merge into one ?

  • Priyank C
    android-layout tags
    In Code I can set and Get multiple Tags using below code.view.setTag(SOURCE_VIEW, R.layout.add_daytime); view.setTag(TARGET_VIEW, R.layout.insert_here);andview.getTag(SOURCE_VIEW); view.getTag(TARGET_VIEW);How setting multiple tags can be achieved at design time (in layout file), I tried below but getting error “Multiple annotations found at this line:- Attribute is missing the Android namespace prefix- Unexpected text found in layout file: “23456”- Open quote is expected for attribute “key” as

  • Kaps
    android android-layout alertdialog android-alertdialog
    I am creating a custom alert dialog, having custom background color. I have defined a theme for that which looks as below,<style name=”MyDialog” parent=”@android:style/Theme.Holo.Dialog”><item name=”android:background”>@android:color/darker_gray</item> </style>The code to make use of this theme looks like below,public class FireDialogFragment extends DialogFragment {String[] stringArray = { “Style1”, “Sytle2”, “Style3” };AlertDialog.Builder builder = new AlertDialog.Build

  • Amir Raminfar
    android button android-layout
    I’m facing a strange problem and I can’t figure out why I systematically get an unexpected stop of my application when I try to inflate the following XML file in the onCreateView of my class which extends the Fragment class :<?xml version=”1.0″ encoding=”UTF-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”android:orientation=”horizontal”android:layout_width=”fill_parent”android:layout_height=”fill_parent” android:background=”@drawable/fond_application_h

  • GrIsHu
    android android-layout r.java-file
    I’ve just installed elipse on my ubantu 13.04 ,but there seems to be a problem ,whenever i make a new project it does not generate the R file for it , i’ve not yet even touched any part of the code neither in XML nor in java ,so human error is not the catch here. I’ve already tried follwing solutionsCheck for errors in XML and Manifest . check if Sdk-platform tools and SDk-tools are installed or notstill i cant get the r file generated ,Help pleaseWell a new turn has come through , maybe the rea

  • f4bzen
    android android-layout layout screen-resolution
    i´m pretty new to android development and creating different layouts for each resolution wasn´t really that easy for me. So, I was able to optimize my app for most devices (in eclipse), but i´m still having some problems here and there:do I really have to copy the same images with different resolutions for each device-resolution into the respective folder? I´m currently using the hdpi, large-hdpi, mdpi and xdpi folders… isnt it possible to use one drawable-folder and just scale the images down

  • Ash
    android-layout android-widget
    I keep getting this error when I put my v7 GridLayout into a Linear Layout:Unexpected namespace prefix “xmlns” found for tag android.support.v7.widget.GridLayoutIf I don’t have the GridLayout within a Linear or Relative layout then it will work fine, but I have to have the GridLayout in some kind of Layout so then scrolling can work but I keep getting the error above?Does someone know to prevent this from happening within a Layout?Thanks for any help.

  • kabuko
    android android-layout android-tablelayout
    I’m using TableLayout to display data. Text of the TextViews of the right column will be set when activity calls onCreate().Now, as you can see in the following image that my address text can be long and it should be wrapped. So I set android:layout_width=”wrap_content”. but it still take a width of screen size to wrap data. How can I overcome from this issue?My xml:<?xml version=”1.0″ encoding=”utf-8″?> <TableLayout xmlns:android=”http://schemas.android.com/apk/res/android”android:layo

  • ThinkDo
    android android-layout android-xml android-studio
    After doing a lot of research, and not finding anything… quick question, does anybody has an idea why Android Studio is not taking the Map tag? The code below is a fragment of the maps sample in the SDK. Already added google play services lib and support, but nothing. It’s showing the errorUnexpected namespace prefix “map” found for tag fragment.Thanks a lot in advance!<fragmentxmlns:map=”http://schemas.android.com/apk/res-auto”android:id=”@+id/map”android:layout_width=”match_parent”androi

  • MikeS
    ios admob iad ads
    I’m using AdMob’s mediation abilities to deliver both iAds and AdMob ads to my iPhone app. However, I’m noticing something REALLY annoying from some of the AdMob ads… Some AdMob ads are opening webpages directly inside my application, in between my Nav bar and Tab bar, and aren’t displaying correctly. Instead of being fully modal like iAds, they are invading my application’s space (and doing it wrong). Are there ways to single out these AdMob ads and disable just the ones that attempt to op

  • poundifdef
    android ant jar admob build.xml
    I maintain an Android app and am not using Eclipse. I am not using Eclipse. I am using ant and build.xml and build.properties. I have places my .jar file into the libs/ directory. My code compiles just dandy. But when I run it on the emulator, the output APK does not include the .jar, so I get a runtime stacktrace:ERROR/AndroidRuntime(470): java.lang.NoClassDefFoundError: com.google.ads.AdViewmy build.properties looks like this:jar.libs.dir=libsAnd the libs/ directory contains my .jar file.What

  • yann.debonnel
    android maven admob
    I have an Android Project where I need to build multiple versions of the same application from the same sources.To do this, I use the android plugin for MavenEach version must be able to include ads from admob. So in my POM I added this dependancy <dependency><groupId>com.admob.android</groupId><artifactId>ads</artifactId><version>20101109-ANDROID-3312276cc1406347</version><scope>system</scope><systemPath>THE_PATH\libs\admob-sdk-android

  • djItu
    iphone ios admob
    Ive been trying to display an interstitial ad several times during my app runtime. Ive read admob documentation about it and it seems that is a one-time-use object, I’d like to know if there’s any workaround for this. Any help will be appreciated. Thanks

  • Guy Cothal
    java android admob manifest
    I have read through about 2 dozen articles and through the Google documents and my code as it is just gives me a force close box. Here is my codeManifest<?xml version=”1.0″ encoding=”utf-8″?> <manifest xmlns:android=”http://schemas.android.com/apk/res/android”package=”com.ndai.funnys”android:versionCode=”1″ android:versionName=”1.0″ ><uses-sdk android:minSdkVersion=”8″ android:targetSdkVersion=”15″ /><uses-permission android:name=”android.permission.INTERNET”/><uses-p

  • KeirDavis
    java android view admob
    So here is my code, super.onCreate(savedInstanceState);RollingThunderView a = new RollingThunderView(this);setContentView(a);adView = new AdView(this, AdSize.BANNER, “ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX”);AdRequest adRequest = new AdRequest();adRequest.addTestDevice(AdRequest.TEST_EMULATOR);adRequest.addTestDevice(“TEST_DEVICE_ID”);adView.loadAd(new AdRequest());android.view.ViewGroup.LayoutParams lp;lp = a.getLayoutParams();lp.width = a.getWidth();lp.height = a.getHeight();this.addContentVie

  • GrIsHu
    android layout admob relative adview
    First off- I have an admob adView set up but I need to create it dynamically due to a bug in the latest release of course.I want the ad on the bottom of the screen, and I have a linearLayout which is set to the bottom BUT there are is a restrictions which have to be otherwise the ad wont load: 1) I need to LinearLayout to be a certain height (NOT wrap content)This all works fine with a test ad, but the problem is…I was going to put this layout in a RelativeLayout so that I can align it to the

  • user1248404
    java android xml admob
    I just added adds to my app, but the moment i run it i get a force close from my phone and there is no logcat. I never declared it in my xml but i dont think i need to…Here’s admob.java: package isaac.n;import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import android.widget.Button; import android.widget.LinearLayout; import android.widget.View

  • user2790945
    layout admob
    Hello I have a problem wich I would like to find the perfect solution for it.I am a publisher in many monetizing platforms like : admob,adfonic..for example in my main layout.I declared admob but if I wanna show adfonic I must do a whole update of my app vercion for my users would see adfonic instead.So is there anyway of control those lines or controling that xml that shows either admob of adfonic ?Thank you very much

  • rommex
    android admob adview
    I’m trying to include ad mob ads to my activity. I did search about this on this site so I did:input code from https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=uk#android imported the newest .jar into /lib included the same .jar in Java Build path as an External JarI cleaned the project, I Ctrl+Shift+O’ed it.Compiling was ok, but runtime I get this error, “Couldn’t find class …..adView”.Sorry if I don’t see an obvious answer. Please help! Thnx

  • nitish patel
    android forceclose
    I want to do some specific piece of code on settings->applications->manage applications->app name->force stop button.How can I get this force stop button event?is it possible to get this event?

  • JavaJavaJava
    java android nullpointerexception mp3 forceclose
    I’m attempting to create an MP3 player inside my app however when I select an MP3 using a file browser, then open it using my app – I get a force close error due to a null pointer exception on the line: playAudio(extras.getInt(MEDIA));How might this be avoided? JAVA:public class MediaPlayerDemo extends Activity {private static final String TAG = “MediaPlayerDemo”;private MediaPlayer mMediaPlayer;private static final String MEDIA = “media”;private static final int LOCAL_AUDIO = 1;private static f

  • dandan78
    android subclass forceclose
    I have created an android project using eclipse.the default system generated code looked as belowpackage com.rmycustomclass.bengler;import android.app.Activity;import android.os.Bundle;public class RMyCustomClassActivity extends Activity {/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);}}I wanted to try a simple custom control , so i changed the code as below. when i search

  • user1145220
    android forceclose
    While calling inbuilt method nextGaussian throws an IllegalMonitorStateException: unlock of unowned monitor double dispersion = RAND.nextGaussian() * 0.2;which is inside@Overridepublic void stroke(Canvas c, float x, float y) { }which is called herecase MotionEvent.ACTION_MOVE:style.stroke(mCanvas, x, y);break;}return true;}then in Surface.java@Overridepublic boolean onTouchEvent(MotionEvent event) {switch (event.getAction()) {case MotionEvent.ACTION_UP:getHistory().saveState();break;}final float

  • Blundell
    android eclipse android-logcat forceclose
    I have a force close error in my code somewhere… I have wrapped the whole of onCreate() in a try catch block to see what it is… but this is not catching it?Is it possible that a force close can occur without throwing an exception object?Thanks.

  • sabadow
    android android-asynctask forceclose
    This call is done in the onCreate:new retreive().execute();The asyncTask class looks like this:class retreive extends AsyncTask<Void,Void,Void>{ProgressDialog dialog = new ProgressDialog(busDisp.this);@Overrideprotected void onPreExecute(){this.dialog.setMessage(“Retreiving Bus Routes…”);this.dialog.show();this.dialog.setCancelable(false);}@Overrideprotected Void doInBackground(Void… arg0) {busRouteJsonParsing();this.dialog.dismiss();return null;}@Overrideprotected void onPostExecute(V

  • user3042650
    android forceclose soundeffect
    I create a project, and this is MainActivity classpackage com.example.myproject;import android.media.MediaPlayer; import android.os.Bundle; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.*;public class MainActivity extends Activity {Button btnmulai, btnpengaturan, btnexit,btninfo; MediaPlayer player;protected void onCreate(Bundle savedInst

  • JustLikeThat
    android orientation saving-data android-dialog forceclose
    I’m working on an app that scans barcodes, when it gets a successful scan it will show a Dialog with the code that was scanned and depending on what was contained within the bar/QR code it will show a button to open a browser, send an SMS, etc. While the Dialog is showing, if the screen changes orientation it crashes. I have got it working to where the orientation can change a couple times before it crashes, but when I check LogCat it says that a NullPointerException is causing the FC. Before I

  • ess.crazy
    android json connection forceclose
    My activity gets force closed when there is no internet connection.How do I prevent this? I am thinking of showing a message to the user that there is no internet connection if it is not connected.In which all ways should I change the code? Thanks in advancepublic class Myclass extends BaseActivity {private String[] imageUrls;private DisplayImageOptions options;private InputStream is;private String result;@SuppressLint(“NewApi”) @Override public void onCreate(Bundle savedInstanceState) {super.on

  • hasanghaforian
    android forceclose android-anr-dialog
    My App Installs successfully on device and emulator.In emulator it starts immediately but on some devices when user clicks on open button in activity that appears after installing App,”ANR” dialog appears and on other devices when user clicks open main Activity opens normally.Finally in all devices when user installs App and clicks on it’s icon in Launcher,main Activity appears normally.Do I forget some things cause this different?

Web site is in building