Unknown error on Rotating Screen

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Unknown error on Rotating Screen

Postby mel » Mon Mar 09, 2009 7:41 pm

I am having an unexpected error when taking the keyboard out...

I only have a simple layout with some inputs and text view...

I initialize them with the attribute: android:visibility="invisible"

and i show them on the screen as they are needed...

when i take out the keyboard to write on the inputs the app shows an unexpected error and finish the app...

NO other screen gives this error...

ANY IDEAS?!?!?!

here some of my code:


Code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. public void onCreate(Bundle savedInstanceState) {
  5.  
  6.         super.onCreate(savedInstanceState);
  7.  
  8.         setContentView(R.layout.verify);
  9.  
  10.  
  11.  
  12.         mTitle = (TextView) findViewById(R.id.info);
  13.  
  14.        
  15.  
  16.         //Initialize variables, Cell number and imei
  17.  
  18.         mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
  19.  
  20.         imei = mTelephonyMgr.getDeviceId();
  21.  
  22.         phoneNum = mTelephonyMgr.getLine1Number();
  23.  
  24.         verification_code="";
  25.  
  26.    
  27.  
  28.         ...
  29.  
  30.  
  31.  
  32.         //initialize button for verifying
  33.  
  34.         button = (Button) findViewById(R.id.verify);
  35.  
  36.         setButton();
  37.  
  38.  
  39.  
  40.         //initialize the verification process;
  41.  
  42.         initialize();
  43.  
  44.     }
  45.  
  46.    
  47.  
  48.    
  49.  
  50.     public void initialize(){
  51.  
  52.        
  53.  
  54.         int readResult = readSettings();
  55.  
  56.        
  57.  
  58.         switch(readResult){
  59.  
  60.         case(0):
  61.  
  62.                         ...
  63.  
  64.                                 showInputs();
  65.  
  66.                 break;
  67.  
  68.         case(1):
  69.  
  70.                         ...
  71.  
  72.         }
  73.  
  74.     }
  75.  
  76.    
  77.  
  78.     public void setButton(){
  79.  
  80.        
  81.  
  82.         button.setOnClickListener(new View.OnClickListener() {
  83.  
  84.             public void onClick(View v) {
  85.  
  86.            
  87.  
  88.                 mTitle.setText("Plase wait...");
  89.  
  90.                
  91.  
  92.                 if( verifyInputs() == true)
  93.  
  94.                 {
  95.  
  96.                         vcode.setVisibility(View.INVISIBLE);
  97.  
  98.                         vcode_input.setVisibility(View.INVISIBLE);
  99.  
  100.                         phone.setVisibility(View.INVISIBLE);
  101.  
  102.                         phone_input.setVisibility(View.INVISIBLE);
  103.  
  104.                         button.setVisibility(View.INVISIBLE);
  105.  
  106.                         ....
  107.  
  108.                     if(response.equals("No"))
  109.  
  110.                     {
  111.  
  112.                         ...
  113.  
  114.                        
  115.  
  116.                      }
  117.  
  118.                      else if(response.equals("Yes"))
  119.  
  120.                      {
  121.  
  122.                         ....
  123.  
  124.                     }
  125.  
  126.                     else{
  127.  
  128.                         ....
  129.  
  130.                     }
  131.  
  132.                 }
  133.  
  134.  
  135.  
  136.             }
  137.  
  138.         });
  139.  
  140.     }
  141.  
  142.  
  143.  
  144. public void showInputs(){
  145.  
  146.         vcode = (TextView)findViewById(R.id.vcode);
  147.  
  148.         vcode_input = (EditText)findViewById(R.id.vcode_input);
  149.  
  150.         phone = (TextView)findViewById(R.id.phone);
  151.  
  152.         phone_input = (EditText)findViewById(R.id.phone_input);
  153.  
  154.        
  155.  
  156.         vcode.setVisibility(View.VISIBLE);
  157.  
  158.         vcode_input.setVisibility(View.VISIBLE);
  159.  
  160.        
  161.  
  162.         if (phoneNum.equals(""))
  163.  
  164.         {
  165.  
  166.                
  167.  
  168.                 phone.setVisibility(View.VISIBLE);
  169.  
  170.                 phone_input.setVisibility(View.VISIBLE);
  171.  
  172.         }
  173.  
  174.                
  175.  
  176.         button.setVisibility(View.VISIBLE);
  177.  
  178.     }
  179.  
  180.  
Parsed in 0.040 seconds, using GeSHi 1.0.8.4



Layout XML:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <TableLayout
  5.  
  6. android:id="@+id/widget0"
  7.  
  8. android:layout_width="fill_parent"
  9.  
  10. android:layout_height="fill_parent"
  11.  
  12. android:orientation="vertical"
  13.  
  14. xmlns:android="http://schemas.android.com/apk/res/android"
  15.  
  16. >
  17.  
  18. <ScrollView
  19.  
  20. android:id="@+id/widget72"
  21.  
  22. android:layout_width="fill_parent"
  23.  
  24. android:layout_height="fill_parent"
  25.  
  26. >
  27.  
  28. <TableLayout
  29.  
  30. android:id="@+id/widget28"
  31.  
  32. android:layout_width="fill_parent"
  33.  
  34. android:layout_height="fill_parent"
  35.  
  36. android:background="#ffffffff"
  37.  
  38. android:padding="30px"
  39.  
  40. android:orientation="vertical"
  41.  
  42. android:stretchColumns="1"
  43.  
  44. >
  45.  
  46. <TableRow
  47.  
  48. android:id="@+id/widget29"
  49.  
  50. android:layout_width="fill_parent"
  51.  
  52. android:layout_height="wrap_content"
  53.  
  54. android:orientation="horizontal"
  55.  
  56. >
  57.  
  58.  
  59.  
  60. <TextView
  61.  
  62. android:id="@+id/widget30"
  63.  
  64. android:layout_width="fill_parent"
  65.  
  66. android:layout_height="fill_parent"
  67.  
  68. android:padding="10px"
  69.  
  70. android:text="Verifying your cell phone."
  71.  
  72. android:textSize="18sp"
  73.  
  74. android:textStyle="bold"
  75.  
  76. android:textColor="#ff333333"
  77.  
  78. >
  79.  
  80. </TextView>
  81.  
  82. </TableRow>
  83.  
  84.  
  85.  
  86. <TableRow
  87.  
  88. android:id="@+id/widget30"
  89.  
  90. android:layout_width="fill_parent"
  91.  
  92. android:layout_height="wrap_content"
  93.  
  94. android:orientation="horizontal"
  95.  
  96. >
  97.  
  98. <TextView
  99.  
  100. android:id="@+id/info"
  101.  
  102. android:layout_width="fill_parent"
  103.  
  104. android:layout_height="fill_parent"
  105.  
  106. android:textColor="#ff000099"
  107.  
  108. android:text="Please wait..."
  109.  
  110. android:padding="10px"
  111.  
  112. >
  113.  
  114. </TextView>
  115.  
  116. </TableRow>
  117.  
  118.  
  119.  
  120. <TableRow
  121.  
  122. android:id="@+id/widget31"
  123.  
  124. android:layout_width="fill_parent"
  125.  
  126. android:layout_height="wrap_content"
  127.  
  128. android:orientation="horizontal"
  129.  
  130. >
  131.  
  132. <TextView
  133.  
  134. android:id="@+id/vcode"
  135.  
  136. android:layout_width="fill_parent"
  137.  
  138. android:layout_height="fill_parent"
  139.  
  140. android:textColor="#ff333333"
  141.  
  142. android:text="Verification Code:"
  143.  
  144. android:textStyle="bold"
  145.  
  146. android:padding="10px"
  147.  
  148. android:visibility="invisible"
  149.  
  150.  
  151.  
  152. >
  153.  
  154. </TextView>
  155.  
  156. </TableRow>
  157.  
  158. <TableRow
  159.  
  160. android:id="@+id/widget33"
  161.  
  162. android:layout_width="wrap_content"
  163.  
  164. android:layout_height="wrap_content"
  165.  
  166. android:orientation="horizontal"
  167.  
  168. >
  169.  
  170. <EditText
  171.  
  172. android:id="@+id/vcode_input"
  173.  
  174. android:layout_width="30px"
  175.  
  176. android:layout_height="40px"
  177.  
  178. android:visibility="invisible"
  179.  
  180. android:numeric="integer"
  181.  
  182. >
  183.  
  184. </EditText>
  185.  
  186. </TableRow>
  187.  
  188.  
  189.  
  190. <TableRow
  191.  
  192. android:id="@+id/widget35"
  193.  
  194. android:layout_width="fill_parent"
  195.  
  196. android:layout_height="wrap_content"
  197.  
  198. android:orientation="horizontal"
  199.  
  200. >
  201.  
  202. <TextView
  203.  
  204. android:id="@+id/phone"
  205.  
  206. android:layout_width="fill_parent"
  207.  
  208. android:layout_height="fill_parent"
  209.  
  210. android:textColor="#ff333333"
  211.  
  212. android:text="Cell Phone:"
  213.  
  214. android:textStyle="bold"
  215.  
  216. android:padding="10px"
  217.  
  218. android:visibility="invisible"
  219.  
  220.  
  221.  
  222. >
  223.  
  224. </TextView>
  225.  
  226. </TableRow>
  227.  
  228. <TableRow
  229.  
  230. android:id="@+id/widget37"
  231.  
  232. android:layout_width="wrap_content"
  233.  
  234. android:layout_height="wrap_content"
  235.  
  236. android:orientation="horizontal"
  237.  
  238. >
  239.  
  240. <EditText
  241.  
  242. android:id="@+id/phone_input"
  243.  
  244. android:layout_width="30px"
  245.  
  246. android:layout_height="40px"
  247.  
  248. android:visibility="invisible"
  249.  
  250. android:numeric="integer"
  251.  
  252.  
  253.  
  254.  
  255.  
  256. >
  257.  
  258. </EditText>
  259.  
  260. </TableRow>
  261.  
  262. <TableRow
  263.  
  264. android:id="@+id/widget915"
  265.  
  266. android:layout_width="wrap_content"
  267.  
  268. android:layout_height="wrap_content"
  269.  
  270. android:orientation="horizontal"
  271.  
  272. >
  273.  
  274. <Button
  275.  
  276. android:id="@+id/verify"
  277.  
  278. android:layout_width="100px"
  279.  
  280. android:layout_height="50px"
  281.  
  282. android:layout_marginLeft="70px"
  283.  
  284. android:layout_marginRight="70px"
  285.  
  286. android:text="Verify"
  287.  
  288. android:textColor="#ff666666"
  289.  
  290. android:visibility="invisible"
  291.  
  292. >
  293.  
  294. </Button>
  295.  
  296. </TableRow>
  297.  
  298. </TableLayout>
  299.  
  300. </ScrollView>
  301.  
  302. </TableLayout>
  303.  
  304.  
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


Manifest:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.  
  3.  
  4. <?xml version="1.0" encoding="utf-8"?>
  5.  
  6. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  7.  
  8.      package="com.mobile.social.net"
  9.  
  10.      android:versionCode="1"
  11.  
  12.      android:versionName="1.0.0">
  13.  
  14.       <uses-permission android:name="android.permission.INTERNET" />
  15.  
  16.       <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  17.  
  18.       <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  19.  
  20.      
  21.  
  22.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  23.  
  24.    
  25.  
  26.    
  27.  
  28.         <activity android:name="verification"
  29.  
  30.                  android:label="Verifying">
  31.  
  32.             <intent-filter>
  33.  
  34.                 <action android:name="android.intent.action.MAIN" />
  35.  
  36.                 <category android:name="android.intent.category.LAUNCHER" />
  37.  
  38.             </intent-filter>
  39.  
  40.         </activity>
  41.  
  42.        
  43.  
  44.         <activity android:name="main_screen" android:launchMode="singleInstance" android:label="MobileSocialNet">
  45.  
  46.         </activity>
  47.  
  48.        
  49.  
  50.         <activity android:name="ListFriends" android:launchMode="singleInstance" android:label="My Friends">
  51.  
  52.         </activity>
  53.  
  54.        
  55.  
  56.         <activity android:name="WallMessage" android:launchMode="singleInstance" android:label="Wall Message">
  57.  
  58.         </activity>
  59.  
  60.     </application>
  61.  
  62. </manifest>
  63.  
  64.  
  65.  
  66.  
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
Attachments
screen.JPG
Screen that gives the error
screen.JPG (18.61 KiB) Viewed 259 times
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Top

Postby MrSnowflake » Mon Mar 09, 2009 8:36 pm

Did you try to lookup the error in the log?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby mel » Tue Mar 10, 2009 5:41 pm

I tried to, but this is what i get with the debug and the log :S and I dont have a clue...
Attachments
keyboard2.JPG
keyboard2.JPG (237.42 KiB) Viewed 245 times
keyboard1.JPG
keyboard1.JPG (233.23 KiB) Viewed 245 times
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Postby mel » Tue Mar 10, 2009 5:58 pm

Maybe something with the layout?

i tried to take out the vertical and horizontal attributes... but it doesn't work...
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Postby MrSnowflake » Tue Mar 10, 2009 7:11 pm

It's pretty obvious: you have a FileNotFoundException (samplefile.txt)

This is just plain java debugging...
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby mel » Tue Mar 10, 2009 9:06 pm

I am sorry to disappoint you MrSnowflake

But actually thats an error that i expect...

The thing is that i only Authenticate the cellphone with my web Service the really first time that he/she goes into the app... then i write a file with the authenticate information in the phone and save it for future actions...

the thing is that in the really first time that the user uses the app it is expected that the file isn't there...

so the authentication is made just when the app get started and it doesn't show any problem... the problem occurs just when I take out the keyboard to write, and it calls a method "performLaunchActivity" as you can see in the debug of the screenshot...

but thx for your help
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Top

Postby MrSnowflake » Tue Mar 10, 2009 11:15 pm

I see now that you have the exception go to stdout, which Dalvik doesn't do.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby mel » Wed Mar 11, 2009 12:10 am

What do you mean when you say that Dalvik (the vm) doesn't do it?
It doesn't support this kind of errors? or what?

The weird thing is that i comment this code of reading the file and any other code that is not related just to the layout... and it stills has the error... :S that's why i think it has to be with the XML layout or something like that...
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Postby mel » Wed Mar 11, 2009 12:35 am

Well... i just found the error :P

the thing is that there are 2 objects in the view that have the same name "@+id/widget30"
And when the Activity tries to refresh the view it gets the exception :)

I just guess it hehe... but thx for your help ;)
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Postby mel » Wed Mar 11, 2009 1:26 am

So, here I am again :P

now I have this problem:

as you can see, i hide and show inputs as i need them on the layout...

the thing is that after the app does the verification process (i have the keyboard physically out in this moment) i hide all the inputs and just show a text that says: Success! But when I close again the keyboard it refresh everything and shows up again all the inputs that i already hide :S

how can i avoid this? or do i have to find a way to catch this thing? :S
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Postby mel » Wed Mar 11, 2009 11:33 pm

Ok well, this is what i found out....

When you hide or open the keyboard the onCreate() method runs because the activity gets restarted and the configuration changes


android:configChanges
Lists configuration changes that the activity will handle itself. When changes that are not listed occur, the activity is shut down and restarted. When a listed change occurs, the activity remains running and its onConfigurationChanged() method is called.



so... i find out that you can control this actions by putting this on your Manifest:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.  
  3.  
  4. <activity ...
  5.  
  6.                  android:configChanges="keyboardHidden|orientation">
  7.  
  8. ...
  9.  
  10. </activity>
  11.  
  12.  
  13.  
  14.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


More information about this here

:) hope this will help someone else with the same problem :)
mel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 12, 2009 6:53 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests