Android Question App hangs when Phone is idle for sometime and when the running logic of the control is 'inside a Do-While Loop' - reg.

beelze69

Active Member
Licensed User
Longtime User
Hi,

I have an issue with a B4A Pages app.

I have a Main Menu Page called 'MainMenu'.

The app has different pages viz. 'Pg1' , 'Pg2' etc.

Now suppose I am in page 'Pg1' and if I leave the b4A App 'idle' for sometime, I want the control to go directly to the Main Menu.

for this I have written the following code:

B4X:
Sub Activity_Pause (UserClosed As Boolean)
    Log("B4X Activity Pause event triggered")
    B4XPages.Delegate.Activity_Pause
    B4XPages.ShowPageAndRemovePreviousPages( "MainPage")
End Sub

However, my App hangs when I again go the 'Pg1'.

What am I doing wrong ?

Requesting for guidance on the same.

Thanks
 

Mahares

Expert
Licensed User
Longtime User
It worked
That is why sometimes you need to upload your project instead of bits and pieces of code and many posts that get deeper and deeper to resolve.
Also, I looked ta your project and saw no reason why you had to try to modify the B4XDateTemplate class. All you needed is to use is a reference to the Xui Views library whci you had. If you were trying a long click on the date selected , it is not workng , but the single click works. I think you are making the project harder than it should be.
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
That is why sometimes you need to upload your project instead of bits and pieces of code and many posts that get deeper and deeper to resolve.
Also, I looked ta your project and saw no reason why you had to try to modify the B4XDateTemplate class. All you needed is to use is a reference to the Xui Views library whci you had. If you were trying a long click on the date selected , it is not workng , but the single click works. I think you are making the project harder than it should be.
Hi Mahares,

Thanks... You are right.. instead of indulging in discussions and making presumptions about 'why android behaves like this or like that'... it is better if greenhorns like us post sample code..

And, by the way...my 'long-click' is working in the post that I sent earlier...You can check that.. Are you saying that there is another way to effect the long-click in the 'DateTemplate' class ? ... Please guide me on the same... I have another doubt... I would like to change the value of a variable declared in the Page (say after the 'Long Click' capture in the DateTemplate) ... How can it be done ? ... Attaching sample code with a sample variable 'variableOnPage' declared in the page..

Requesting for guidance on the same.

Thanks..
 

Attachments

  • testCode.zip
    12.8 KB · Views: 138
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I would like to change the value of a variable declared in the Page (say after the 'Long Click' capture in the DateTemplate) ... How can it be done ?
I am afraid I do not understand the question.. You have a variable called: variableOnPage declared in Globals in your project, but your do not say what it represents. I defer the answer to someone else who does understand the question.
By the way both the short and long click on the selected date do the same thing in the project you attached in post 23
I still do not undestand why you are using a modified B4XDateTemplate class, instead of simply referencing the library XUI Views. It makes no sense.
 
Last edited:
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
I am afraid I do not understand the question.. You have a variable called: variableOnPage declared in Globals in your project, but your do not say what it represents. I defer the answer to someone else who does understand the question.
By the way both the short and long click on the selected date do the same thing in the project you attached in post 23
I still do not undestand why you are using a modified B4XDateTemplate class, instead of simply referencing the library XUI Views. It makes no sense.
Hi Mahares,

You can refer the code.. I have declared it as a string variable in the b4xPage..
All I want is somebody to help me to reference that variable in the DateTemplate class and assign any sample value say 'test' etc. to it..

The issue is that ..I want to make the assignment to that variable in the DateTemplate class... Purpose you do not worry... My basic purpose of attaching the code is to know as to how you will reference a value of a variable declared in one page in another class /another page... That's all...

And regarding the 'Short and the Long-Click', you can see that I have trapped correctly the 'Click' and the 'Long Click' ... and it works fine for me ... It does not do anything in the code that I have given you ... Actually I do lot of different things when a long-click is done and when a click is done while selecting a day of a date in the DateTemplate class.... That part you do not have to worry about... That part is already done ... I had attached that DateTemplate class code to Agraham only for finding a solution to my earlier 'hanging issue' which he has already addressed...My intention of sending the 'modified DateTemplate class' to Agraham was my way of saying that 'I have not made any change in the DateTemplate class apart from trapping for the 'click' and the 'long-click' ).. That's all.. I never had any doubts regarding the trapping of the 'Click' and 'Long Click'... It works fine...

Now.. from your earlier posts it appears that 'there is another way to trap the long-click/click in the DateTemplate class apart from the way I have done... You are saying 'referencing the library XUI Views'.. I did not get that..

Summarising,

i) Requesting for showing how to'assign a value to the variable 'variableOnPage' which I have declared as a string variable on the page in the DateTemplate Class [you can assign any value to it in the DateTemplate class and show as a log entry in the DateTemplate Class..You can show it anywhere in that class.. I just what to know how you will trap that variable in that class and make the assignment..That's all..)...

ii) Can you modify the code in that DateTemplate class suitably and show me another way (you are saying 'referencing the library XUI Views etc.') to trap the 'Click' and the 'Long-Click'... My purpose is to trap the Click and the Long-Click when I press on a day of a particular date in the DateTemplate class .... I am just asking if there is another way to do it ...

Thank you for your guidance and views.
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
Here's one way, there may be others.
B4X:
' In B4XMainPAge
Sub Class_Globals
   '...
    Public variableOnPage As String ' Must be declared Public
End Sub


' In DateTemplate class

Dim page As B4XMainPage = B4XPages.GetPage("B4XmainPAge")
page.variableOnPage = "Test"
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
how you will reference a value of a variable declared in one page in another class /another page... That's all...
All you need to do is declare it as public, say in B4XmainPage in Globals
B4X:
Public variableOnPage As String
and you can refer to it in any other page as: B4XPages.MainPage.variableOnPage.
If you declare it as public in Page2 for instance, you refer to it in B4XMainPage as: Page2.variableOnPage
As for refernce to XUI Views. What I meant is that you do not need a class module if you put a check in the library pane for XUI Views because B4XDateTemplate is part of XUI Views lib. I did not say anything about click or long click.
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
All you need to do is declare it as public, say in B4XmainPage in Globals
B4X:
Public variableOnPage As String
and you can refer to it in any other page as: B4XPages.MainPage.variableOnPage.
If you declare it as public in Page2 for instance, you refer to it in B4XMainPage as: Page2.variableOnPage
As for refernce to XUI Views. What I meant is that you do not need a class module if you put a check in the library pane for XUI Views because B4XDateTemplate is part of XUI Views lib. I did not say anything about click or long click.
Hi Mahares,

I will try that variable declaration and revert back if there are any issues..

Thank you very much..
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Here's one way, there may be others.
B4X:
' In B4XMainPAge
Sub Class_Globals
   '...
    Public variableOnPage As String ' Must be declared Public
End Sub


' In DateTemplate class

Dim page As B4XMainPage = B4XPages.GetPage("B4XmainPAge")
page.variableOnPage = "Test"
Hi Agraham,

Thanks a lot..
I will try it out...
 
Upvote 0
Top