This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Android and the fly likes Why not correct run my program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Why not correct run my program?" Watch "Why not correct run my program?" New topic
Author

Why not correct run my program?

fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
I want to create a page that bottom of page is 5 buttons and the rest of the page is for when user press one of the buttons. I created this but when i pressed Home button, the program does nothing and not open html file. Why?

res/layout/activity_main.xml


res/values/colors.xml


res/values/strings.xml


assets/index.html


home.java
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Is the onClick method being called? Are there any exceptions in the logcat output?


Ping & DNS - my free Android networking tools app
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Ulf Dittmer wrote:Is the onClick method being called? Are there any exceptions in the logcat output?


Thanks for answer. I copy logCat and past here:

10-22 23:18:52.549: D/OpenGLRenderer(11209): Flushing caches (mode 0)
10-22 23:18:52.705: D/OpenGLRenderer(11209): Flushing caches (mode 1)
10-22 23:19:03.823: D/libEGL(11269): loaded /system/lib/egl/libGLES_android.so
10-22 23:19:03.830: D/libEGL(11269): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
10-22 23:19:03.838: D/libEGL(11269): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
10-22 23:19:03.838: D/libEGL(11269): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
10-22 23:19:03.932: D/OpenGLRenderer(11269): Enabling debug mode 0
10-22 23:22:47.174: D/dalvikvm(11269): GC_FOR_ALLOC freed 149K, 2% free 14272K/14535K, paused 35ms
10-22 23:26:21.893: D/OpenGLRenderer(11269): Flushing caches (mode 0)
10-22 23:26:22.034: D/OpenGLRenderer(11269): Flushing caches (mode 1)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Is that all? There aren't even messages about the app being started, so it doesn't seem to be the full output. Also:
Is the onClick method being called?
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Ulf Dittmer wrote:Is that all? There aren't even messages about the app being started, so it doesn't seem to be the full output. Also:
Is the onClick method being called?

I unistalled the program on the phone and run the program again. I copy everything writes in logCat tab:

10-22 23:42:15.096: D/libEGL(12120): loaded /system/lib/egl/libGLES_android.so
10-22 23:42:15.096: D/libEGL(12120): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
10-22 23:42:15.104: D/libEGL(12120): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
10-22 23:42:15.104: D/libEGL(12120): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
10-22 23:42:15.205: D/OpenGLRenderer(12120): Enabling debug mode 0
10-22 23:42:15.354: D/dalvikvm(12120): GC_CONCURRENT freed 185K, 3% free 14279K/14599K, paused 3ms+3ms

I dont know what should i know the onClick method being called or not? Please explain for me.
Thank you. Cheers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
You can put a Log.i method call into the onClick handler.
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Ulf Dittmer wrote:You can put a Log.i method call into the onClick handler.


I edit the loyaltier.java class:



Do i correct write log.i("test","I AM HERE"); ? I copy logCat and paste in below:

10-24 00:30:55.038: D/libEGL(5340): loaded /system/lib/egl/libGLES_android.so
10-24 00:30:55.046: D/libEGL(5340): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
10-24 00:30:55.046: D/libEGL(5340): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
10-24 00:30:55.053: D/libEGL(5340): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
10-24 00:30:55.139: D/OpenGLRenderer(5340): Enabling debug mode 0
10-24 00:31:00.960: D/OpenGLRenderer(5340): Flushing caches (mode 0)
10-24 00:31:01.022: D/OpenGLRenderer(5340): Flushing caches (mode 1)
10-24 00:31:01.499: D/dalvikvm(5340): GC_FOR_ALLOC freed 167K, 2% free 14272K/14535K, paused 19ms

Where is my problem? How to fix it?
Thank you. Cheers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
If that's really the entire logcat output - and it doesn't really look like it is, you should verify that writing to the log works by adding more Log.i calls to your code, e.g. at the start of the onCreate method- then it would seem that the onClick handler is not being called.
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Thanks.I download my program and if you can please read my code and say to me, what is my problem? Cheers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
I'm not sure what the problem is. That's why I suggested you start debugging the issue by putting log statement all over the code, so that you can be sure about which code is executed, and which is not. So far, I'm not even convinced that logging works, though.
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
I couldnt see logCat of previous my program because i write other program again and add log.i() function to my code. I write the code and logCat of program. I think when button clicked, the program not load web page. Why? Please please help me.

MainActivity:



Activity_main.xml


strings.xml



LogCat:




Cheers
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Are you really using spaces in your android_id attributes, or is that just an artifact of copy/paste?

Edit: Scratch that; I now see that it's a browser thing.
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Ulf Dittmer wrote:Are you really using spaces in your android_id attributes, or is that just an artifact of copy/paste?

Edit: Scratch that; I now see that it's a browser thing.


Thanks for answer.
I also ask this question in stackoverflow site and they say to me that i forgot add internet permission to AndroidManifest.xml and i add this to androidManifest.xml, the program runs but when i changed my code and add Go.java to my project and changed MainActivity , the program not runs again Why? Where and what is the problem?

stackoverflow

Sorry for my questions.
Thank you.
Cheers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
You probably didn't change it everywhere it needs to be changed, like in the manifest. Are there any exceptions in the stack trace?
fahimeh hashemian
Ranch Hand

Joined: Aug 07, 2012
Posts: 84
Thanks for help

I copy MainActivity and Go.java and strings and ... in below. Where is the problem? Do i have any problem in code? if you need any file of my program, please tell me, so i write that.

Go.java


MainActivity:



Activity_main.xml:



strings.xml:



AndroidManifest.xml:



Cheers.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Start with this:
Ulf Dittmer wrote:Are there any exceptions in the stack trace?


(I didn't really mean "stack trace", I meant "logcat output", but either way, the important part is "are there any exceptions?")
 
jQuery in Action, 2nd edition
 
subject: Why not correct run my program?
 
Similar Threads
Layout issue-footer image to the bottom of screen (Landscape & portrai) irrespective of body content
ListView textColor
Layouts, bottom position
Maps are not show in Emulator
Problem with Table view