|
![]() |
Norm Radder wrote:Can you save the value in decrypted1 in a class level variable and pass it to the constructor for the Decrypt2 class?
Norm Radder wrote:Declare decrypted1 before the onCreate method so it is at class level. Then assign it a value on line 39. That value will be available when the Decrypt2 class is created.
There is a problem with the loop that the assignment statement is in. Only the last value assigned to decrypted1 will be available when the Decrypt2 constructor is called.
how it would retain the decrypted password valume from the encrypted password from the URI query if it's declared before the onCreate method.
Norm Radder wrote:
how it would retain the decrypted password valume from the encrypted password from the URI query if it's declared before the onCreate method.
The declaration of the variable does not need to assign it a value. It's initial value would be null. When line 39 is executed it would be assigned the value. New line 39:
Norm Radder wrote:
how it would retain the decrypted password valume from the encrypted password from the URI query if it's declared before the onCreate method.
The declaration of the variable does not need to assign it a value. The variable's initial value would be null. When line 39 is executed it would be assigned the value. New line 39:
I'm not able to get Decrypt2 class to use decrypted1
Norm Radder wrote:Yes that looks like what I was talking about for placing a declared variable.
I'm not able to get Decrypt2 class to use decrypted1
How are you passing the value of decrypted1 to the Decrypt2 class?
I've been trying to create a constructor,
Norm Radder wrote:Passing a value to a constructor is very basic java. How did you get to this point in your programming without learning how to use a class constructor?
Here is a link to the tutorial re constructors: https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html
I've been trying to create a constructor,
If you are having problems with the code, you need to post the code and the error messages or a description of the problem.
Norm Radder wrote:Several problems I see:
decrypted1 is declared in two places: line 8 and line 41. The local declaration on line 41 masks the declaration on line 8. Remove the declaration on line 41 and make it an assignment statement. See post Yesterday 4:10 PM
The value of decrypt1 should be passed in the constructor to the Decrypt2 class. Once the constructor gets that value it can be used to compute the value of secretKeySpe. The existing code uses a new instance of MainActivity(not the one with the desired value) to access the value of decrypted1 which will not have a value in the new instance.
No, line 8 was required to declare decrypt1 at the class level. What needed to be changed was line 41 so it was only an assignment statement that assigned a value to the variable declared on line 8.I removed line 8,
Norm Radder wrote:
No, line 8 was required to declare decrypt1 at the class level. What needed to be changed was line 41 so it was only an assignment statement that assigned a value to the variable declared on line 8.I removed line 8,
The purpose of the constructor I described was to accept the value of decrypt1 and save it so that it could be used to compute the value of secretKeySpe.
The statement that computes secretKeySpe needs to be inside of the constructor so that it can use the passed value of decrypt1. The declaration of secretKeySpe needs to be at the class level the same as with decrypt1 in the MainActivity class.
What's brown and sticky? ... a stick. Or a tiny ad.
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
|