The emulator can not run these..Help!?

awakenblueheart

Member
Licensed User
Longtime User
First layout

........................................................
'Activity module
Sub Process_Globals

End Sub

Sub Globals
Dim equationmaxpower As EditText
Dim maxpowr As Double
Dim coefficient As Double
'Dim resultss As Double
Dim i As Double
Dim cofx() As Double
Dim coDfx() As Double
Dim a As Double
Dim maxpowrDfx As Double
'Dim eps As Double 'epsilon

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("findrootLayout")
End Sub

Sub findrootButton_Click


If equationmaxpower.Text = "" Then
Msgbox("Insert a value","")
Return
Else

If equationmaxpower.Text = 0 Then
Msgbox("Insert a value more than 0","")
Return

Else
If Not(equationmaxpower.Text = "") Then
maxpowr = equationmaxpower.Text
coefficient = maxpowr + 1

Dim cofx(maxpowr) As Double
Dim coDfx(maxpowr - 1) As Double


coDfx(0) = 0

For i = 0 To maxpowr
StartActivity(Submain)
a = Submain.coefficient2
cofx(i) = a
Next



maxpowrDfx = maxpowr - 1

For i = 0 To maxpowrDfx
coDfx(i) = cofx(i) * (maxpowr - i)
Next


' eps = 1
' While eps + 1 > 1
'eps = eps / 2
'End While



'resultss = results(eps, cofx, coDfx, maxpowr, maxpowrDfx)
'root.Text = resultss
End If
End If
End If
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
............................................................

Below is the second layout.
............................................................

'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim coefficient2 As Double
coefficient2=""
End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim coefficient As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("2")
End Sub

Sub next_Click

If coefficient.Text = "" Then
Msgbox("Insert a value","")
End If
If Not (coefficient.Text = "") Then
coefficient2= coefficient.Text
StartActivity(Main)
End If
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
....................................................................

The emulator said "The application find root (process awaken.findRoot0 has stopped unexpectedly.Please try again"
 

awakenblueheart

Member
Licensed User
Longtime User
I did not understand what's the issue

LogCat connected to: emulator-5554
debuggerd: Feb 3 2011 14:45:34



java.lang.RuntimeException: java.lang.NumberFormatException:
at awaken.findRoot.main.initializeProcessGlobals(main.java:369)
at awaken.findRoot.main.afterFirstLayout(main.java:80)
at awaken.findRoot.main.access$100(main.java:16)
at awaken.findRoot.main$WaitForLayout.run(main.java:72)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException:
at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:267)
at java.lang.Double.parseDouble(Double.java:318)
at awaken.findRoot.submain._process_globals(submain.java:308)
at awaken.findRoot.main.initializeProcessGlobals(main.java:366)
... 12 more
Force finishing activity awaken.findRoot/.main
Activity pause timeout for HistoryRecord{40687648 awaken.findRoot/.main}
GC_EXPLICIT freed 8K, 54% free 2542K/5511K, external 716K/1038K, paused 91ms
Activity destroy timeout for HistoryRecord{40687648 awaken.findRoot/.main}
GC_EXPLICIT freed 321K, 54% free 2538K/5511K, external 716K/1038K, paused 72ms
request time failed: java.net.SocketException: Address family not supported by protocol


GC_CONCURRENT freed 228K, 51% free 2807K/5703K, external 956K/1038K, paused 10ms+7ms
 
Upvote 0

awakenblueheart

Member
Licensed User
Longtime User
Sorry

I'm sorry for the copying all error..
someway I heard Erel then my program can run.
Now, I get a problem..Here:
My program had two activity.
In first activity(Main), an edittext will get a value.Let say A.
Also,in second activity(Submain), an edittext will get a value.Let say B.
Value A will make a loop to call secondactivity like this

For i = 0 To maxpowr 'maxpower is A
StartActivity(Submain)
a = Submain.coefficient2 'coefficient2 is B
cofx(i) = a
Next

Then,the secondactivity will get a value B.
When I press next button, I want the value store in the array above and then continue the looping.

Please reply me..I had post my code in previous reply
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
First of all, it is difficult to find the problem without filtering the logs.
Anyway, you start a new activity from inside a loop, obviously wanting to get data to fill the first activity. Now, I think this is wrong, and probably the cause of your problem. I would suggest that you enter the coefficients in a simple panel, at your first form. Something like this:
B4X:
'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
Dim equationmaxpower As EditText
Dim findrootButton As Button 
Dim maxpowr As Double
Dim coEfficient As Double
'Dim resultss As Double
Dim i As Double
Dim cofx() As Double
Dim coDfx() As Double
Dim a As Double
Dim maxpowrDfx As Double
Dim pn As Panel 
Dim btnNext As Button 
Dim coEfficientText As EditText
Dim coEffCounter As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
equationmaxpower.Initialize ("")
Activity.AddView (equationmaxpower,0,0,50%x,10%y)
findrootButton.Initialize ("findrootButton")
findrootButton.Text="set coeff"
Activity.AddView (findrootButton,0,20%y,50%x,10%y)
pn.Initialize ("pn")
btnNext.Initialize ("next")
btnNext.Text="Next"
coEfficientText.Initialize ("")
coEfficientText.Text=""
pn.Visible =False
Activity.AddView (pn,0,0,50%x,40%y)
pn.AddView (coEfficientText,0,0,40%x,10%y)
pn.AddView (btnNext,0,20%y,40%x,10%y)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub findrootButton_Click


If equationmaxpower.Text = "" Then
    Msgbox("Insert a value","")
    Return
Else
    If equationmaxpower.Text = 0 Then
        Msgbox("Insert a value more than 0","")
        Return
    Else
        Try
            ' you don't need this. you've checked already for that above
            'If Not(equationmaxpower.Text = "") Then
            maxpowr = equationmaxpower.Text
            coEfficient = maxpowr + 1
            Dim cofx(maxpowr+1) As Double
            Dim coDfx(maxpowr) As Double
            coDfx(0) = 0
            i=0
            btnNext.Text="Enter coeff" & (i+1)
            pn.BringToFront :pn.Color=Colors.Blue 
            pn.Visible =True
            coEfficientText.RequestFocus
        Catch
            Msgbox("enter a number","error")
        End Try
    End If
End If
End Sub



Sub next_Click

If coEfficientText.Text = "" Then
    Msgbox("Insert a value","")
Else
    Try
        cofx(i)= coEfficientText.Text
        If i<maxpowr-1 Then
            coDfx(i)=cofx(i)*(maxpowr-i)
        End If
        i=i+1
        If i<=maxpowr Then
            coEfficientText.Text=""
            coEfficientText.RequestFocus
            btnNext.Text="Enter coef" & (i+1)
        Else
            pn.Visible =False
            ' from here, proceed to whichever sub you want to go on
            ' just an example
            Dim tempS As String 
            tempS=""
            For j=0 To maxpowr
                tempS=tempS & "coeff "& (j+1) & " = " & cofx(j) & CRLF
            Next
            Msgbox(tempS,"finished")
        End If
    Catch
        Msgbox("enter a number","error")
    End Try
End If

End Sub
 
Upvote 0

awakenblueheart

Member
Licensed User
Longtime User
Thnks

I have to thank you for the great reply..I am just very beginner and only had some little knowledge in vba and java..Sorry. Can you give link of tutorial to understand the code of android better.
Your code is work and thanks for reply but I still thinking doing it in two activity..Can it be done..?
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I have to thank you for the great reply..I am just very beginner and only had some little knowledge in vba and java..Sorry. Can you give link of tutorial to understand the code of android better.
Your code is work and thanks for reply but I still thinking doing it in two activity..Can it be done..?
Sure it can be done. You have to load the code of the panel, to your new activity. When you finish entering data, you start again the previous activity, setting a boolean flag to true, to notify the previous activity that data arrived. (I think there are other ways for this too, others may help you more).
I think you should start from Klaus beginner's guide, here: http://www.b4x.com/forum/basic4android-getting-started-tutorials/9578-beginners-guide.html#post53042
 
Upvote 0
Top