Call with a button a saved number in another page( IONIC, Angular) - android

Hi I want to call a number which is saved in another page.
I don't know how to explain this well but I put some captures, and the code that I'm trying to use, I just only want to catch the value of the number and put into the button to call.
I'm using ionic framework and angular. I'm very new at this but I want to create an app and I'm stuck with this.
Sorry for my english is not my native language.
Client Detail
Call button
Button page .ts
Detail html page(the first image)
button page html (click) function

import { ICompanyAddress } from './../interfaces/Map';
import { Injectable } from '#angular/core';
#Injectable({
providedIn: 'root'
})
export class SharedDataService {
_phoneNumber: string;
constructor() { }
get phoneNumber(): string {
return this._phoneNumber;
}
set phoneNumber(newValue: string) {
this._phoneNumber = newValue;
}
}
Now You could change access its data from any page and changing its value:
example1 (change phoneNumber from a page)
constructor(private sharedDataService : SharedDataService) {
this.changePhoneNumber()
}
changePhoneNumber(){
this.sharedDataService.phoneNumber = '12345678'
}
example1 (get last phoneNumber changed value in a page)
constructor(private sharedDataService : SharedDataService) {
console.log(this.sharedDataService.phoneNumber)// 12345678
}

For that, you can create services and then store your PhoneNumber in services.
Check this out .I hope it will help you.

Related

how to reload getx controller?

hi I try using Getx Controller in flutter. I want my oninit of controller reload and set the new data each time user go two my certain page, but only the first time page reload oninint excute. how can I set onInit reload each time user go to this page?
my onInit code is:
#override
Future<void> onInit() async {
super.onInit();
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
name = (sharedPreferences.getString('name') ?? '-1').obs;
avatarImage = (sharedPreferences.getString('imageAddress') ?? '-1').obs;
username = sharedPreferences.getString('username') ?? '-1';
file = File(avatarImage.value);
}
Since the controllers aren't named, I will say that we have a ReloadedController which contains the onInit() in your code snippet, and we have the SpecificPageController that belongs to that specific page.
I can think of two solutions that will suit your case:
First sulution: delete the controller and inject it again, to execute the onInit():
class SpecificPageController extends GetxController {
#override
void onInit() {
Get.delete<ReloadedController>();
Get.put(ReloadedController());
super.onInit();
}
}
This will delete the ReloadedController from the memory, then inject it again, this will trigger the OnInit() to execute since we just injected it.
Second solution: forcefully execute the onInit() method:
class SpecificPageController extends GetxController {
#override
void onInit() {
Get.find<ReloadedController>().onInit();
super.onInit();
}
}
This will execute forcefully the OnInit() method, which will behave like a reload for your onInit() code every time the specific page will be opened.
Third, solution: using onGenerateRoute
return GetMaterialApp(
onGenerateRoute: (settings) {
if (settings.name == "/yourSpecificPageRoure") {
name = (sharedPreferences.getString('name') ?? '-1').obs;
avatarImage =
(sharedPreferences.getString('imageAddress') ?? '-1').obs;
username = sharedPreferences.getString('username') ?? '-1';
file = File(avatarImage.value);
}
},
// ...
Change /yourSpecificPageRoure with your route path name.
This method is called every time a route is generated in your app, the price of your code will be executed only when the route name is /yourSpecificPageRoure.

i can't make a contact between the activities in Kotlin

Hello this is my first app with kotlin i am trying to make annual rate calculation app the problem is i have 4 activities every activity own button and edit's texts
i wan't when The User click the button, the program get the numbers from Edit's texts and only make the calculation and save it somewhere and same work for the activity 2 and 3.
but when he click the last button of the last activity i want to call all the results and show it in ViewText
The Question is:How to save data Every time somewhere and call when i need it?
First Activity
class st {
var int_P: Double? = null
var ctl_P: Double? = null
public constructor(int_P: Any, ctl_P: Any) {
this.int_P = int_P.toString().toDouble() //Physique
this.ctl_P = ctl_P.toString().toDouble()
public fun GetMP(): Double {
return (this.int_P!! + (this.ctl_P!! * 2)) / 3
}
}
Btn_Next1.setOnClickListener ({
var int_P = java.lang.Double.parseDouble(edit_IP.text.toString()) //Physique
var ctl_P = java.lang.Double.parseDouble(edit_CP.text.toString())
var ss = st(int_P,ctl_P)
val ic = Intent(this, Sec_Act::class.java)
startActivity(ic)
})
(Secend and Third Activity Same)
Activity 4
btn1.setOnClickListener ({
var act1 = MainActivity.st().GetMC()
Textv.text = act1.toString()
})
With this method i got problem (no value passed for parameter int_P , ctl_P)
There are many different ways to send information back to an Activity:
onActivityResult(),
having a singleton class,
use Shared Preferences,
headless fragments,
sqlite database,
store the information in a file.
Intents
receivers
You need to determine which will be the best solution for you. Whether it's kotlin or java, the methodology will be the same.

React Native: Integration With Existing Apps

I'm new to react and I followed the tutorial about integrating existing apps open in the React Native Docs.
private ReactRootView mReactRootView;
.......
Bundle launchOptions = new Bundle();
launchOptions.putBoolean("test", true);
//mReactRootView.startReactApplication(mReactInstanceManager, "ThirdAwesomeComponent", launchOptions);
mReactRootView.startReactApplication(mReactInstanceManager, "ThirdAwesomeComponent", null); // Actual example
Is there a way to read launchOptions in the HelloWorld Component at index.android.js?
Also I have two activities from where I need to call the react native daemon and want to render two different layouts returned by the server.
How can I do that since currently I only have one:
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
The best way to do is doing something like,
Redirect to App.js from the index page using
AppRegistry.registerComponent("App",()=>App)
This will redirect to app
Then for rendering two different scenes based on server output. You can create a state variable and initialize it to be the default state.
in the render function of you component you can then check the state value and assign the layout as per your necessity.
Use something like
export default Class App extends Component{
constructor(props){
super(props)
this.state{
data1:false,
data2:true,
loaded:false,
}
}
//do all the fetching data to server here
componentWillMount(){
//after fetching the data to server
change the state as
this.setState({
data1:true,
data2:false,
loaded:true
})
}
render({
if(this.state.loaded && this.state.data1){
return(
//layout which you want to return
)
}else if( this.state.loaded && this.state.data2){
return(
//second layout code
)
}else{
return(
//can create a loading spinner here
<Text>Loading.....</Text>
)
}
})
}
Hope this helps
Cheers
Your launching options will be passed to the constructor of your component as props.
Just implement the constructor
constructor(props){
super(props)
// do stuff to pops dictionary
}

SAPUI5 navigation between apps definitions

I'm new in SAPUI5 development and I'd like to know how can I navigate through different apps definitions.
In my case, I'm developing a mobile app that uses the sap.m.App and in some views I'd like to use sap.m.splitApp.
First, I have a login page and a tile container with some options. Depending on the user's choice, I'm showing an splitApp with master and detail page.
Main App Controller: With this method I can navigate to my splitApp view
toApp: function (pageId, context) {
var app = this.getView().app;
// load page on demand
var master = ("Login" === pageId);
if (app.getPage(pageId, master) === null) {
var page = sap.ui.view({
id : pageId,
viewName : "view." + pageId,
type : "JS",
viewData : { component : this }
});
page.getController().nav = this;
app.addPage(page, true);
console.log("app controller > loaded page: " + pageId);
}
// show the page
app.to(pageId);
// set data context on the page
if (context) {
var page = app.getPage(pageId);
page.setBindingContext(context);
}
},
Ticket.view.js: Here I add my master and detail pages to my App
createContent : function(oController) {
// to avoid scroll bars on desktop the root view must be set to block display
this.setDisplayBlock(true);
// create app
this.app = new sap.m.SplitApp();
// load the master page
var master = sap.ui.xmlview("MyTicketsList", "view.MyTicketsList");
master.getController().nav = this.getController();
this.app.addPage(master, true);
// load the empty page
var empty = sap.ui.xmlview("Empty", "view.Empty");
this.app.addPage(empty, false);
return this.app;
}
And it's working fine. I can navigate to my splitApp. The problem is that I have to go back to my Main page (with the tile container) in case the user choice other option. I hope to do that using the following method in my Ticket.controller.js
back : function (pageId) {
this.getView().app.backToPage(pageId);
}
And, on the MyTicketsList controller, I did the handleNavButtonPress using:
this.nav.back("MainPage");
But this, doesn't work!
How can I navigate through apps? Or, perhaps, How is the better way to create my splitter pages view, with Master and Detail pages?
P.S.: I'm following this tutorial
Thanks in advance!
In the splitApp first you should instantiate the view as
oSplitApp.addDetailPage(your view);
then to navigate from the splitapp use,
oSplitApp.toDetailPage(your view);
It's easier than it appears.
I had the same problem and to make the SplitApp preview you just have to call the view like a normal XML view but Insert the TAG
onInit: function() {
this.bus = sap.ui.component(sap.ui.core.Component.getOwnerIdFor(this.getView())).getEventBus();
},
doNavBack: function(event) {
this.bus.publish("nav", "to", {id : "Page1"});
},

How to use adapter inside the application in worklight

Im new to worklight. Now im started using adapter. Check this link one of my stackoverflow friend have same doubt click this Calling the procedure inside the application. The Adapter im using is SqlAdapter. But in the ibm worklight tutorial they gave example for HttpAdapter and clubing the procedure inside the function. But not for SqlAdapter. If any suggestion kindly let me know. if u want to my source i will ready to provide. Still my research continues
The call from an application to an adapter is the same for all types of adapters.
function getData() {
var invocationData = {
adapter : 'ADAPTER_NAME',
procedure : 'PROCEDURE_NAME',
parameters : []
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : getDataSuccess,
onFailure : getDataFailure,
});
}
For more information check module 6 - Invoking Adapter Procedures from the Client Applications (PDF, 370KB) and the exercise and code sample (ZIP, 53.7KB)
Here i retrieved the values. but its not displaying in html page. this is my code
function wlCommonInit(){
// Common initialization code goes here
WL.Logger.debug("inside the wlcommoninit");
busyIndicator = new WL.BusyIndicator('AppBody');
getData();
}
function loadFeedsSuccess(result){
WL.Logger.debug("Feed retrieve success");
}
function loadFeedsFailure(result){
WL.Logger.error("Feed retrieve failure");
}
function getData() {
var invocationData = {
adapter : 'SqlAdap',
procedure : 'procedure1',
parameters : []
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : loadFeedsSuccess,
onFailure : loadFeedsFailure,
});
}

Categories

Resources