I am trying to invoke and android app with certain perameters, can someone please assist me by trying to convert the following code into flutter, I am using the Android Intent flutter package but not having much luck.
Below is the code that i am trying to convert from Native android / Groovy to flutter
val launchIntent = Intent()
launchIntent.action = "CenDroid"
launchIntent.putExtra("Operation", "Sale")
// Get the time
val millisecond: Long = java.lang.System.currentTimeMillis()
val timeString = milliseconds.toString()
launchIntent.putExtra("Time", timeString)
launchIntent.putExtra("Caller", "Caller Name")
// InvocationKey is Sha512 of Sha256 of Sha1 of whatever is sent in the Time field.
var hashed = HashUtils.sha1(timeString)
hashed = HashUtils.sha256(hashed)
hashed = HashUtils.sha512(hashed)
launchIntent.putExtra("InvocationKey", hashed)
launchIntent.putExtra("Amount", 100.0F)
launchIntent.flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
startActivityForResult(launchIntent, 1)
Any assistance would be of great help
Flutter navigate one page to another page by using this
Navigator.push(
context,
MaterialPageRoute(builder: (context) =>SecondRoute()),
);
to see parameter pass from one page to another page
Passing data
Related
I have an android app, I integrated a flutter module into it based on https://docs.flutter.dev/development/add-to-app/android/project-setup.
I managed to get calling flutter activity working, even sending extra data with intent and getting response data from flutter too.
What I want to do is the equivalent of calling startActivity(intent), just from my flutter module.
How could I achieve this? Is my only way is deeplinking?
I managed to make this work by using the package "android_intent_plus". From there, all I had to do was use this code:
var intent = AndroidIntent(
package: "my.custom.package",
componentName: "my.custom.package.MyAndroidActivity",
arguments: {
"DATA_KEY": "Data to send",
},
);
await intent.launch();
However, this solution is not perfect as of date, because I cannot receive result this way.
I have following problem. I just can't figure out how to initialize WalletConnect and connect to Metamask on Android. I always get following exception.
java.lang.NoSuchMethodError: No interface method getInitializationErrorsFlow()Lkotlinx/coroutines/flow/Flow; in class Lcom/walletconnect/android/internal/common/model/JsonRpcInteractorInterface;
My code looks as follows:
val projectId = "15f2b4ae8bb12dsd3d267ce6441d5a9d" // I got the Project ID from https://cloud.walletconnect.com/
val relayUrl = "relay.walletconnect.com"
val serverUrl = "wss://$relayUrl?projectId=$projectId"
val connectionType = ConnectionType.AUTOMATIC
val appMetaData = Core.Model.AppMetaData( // <-- What data should be entered here?
name = "Metamask",
description = "Description",
url = "Wallet Url", // How can I get the wallet url?
icons = listOf(""),
redirect = "kotlin-wallet-wc:/request"
)
CoreClient.initialize(relayServerUrl = serverUrl, connectionType = connectionType, application = application, metaData = appMetaData)
val init = Sign.Params.Init(CoreClient)
SignClient.initialize(init, onError = { error ->
})
Are you calling all initialize methods inside the Application onCreate() method? We have a demo wallet to showcase how it should be done here
enter code here
wc:a593bc04-32b5-4e25-aaec-9e2c247e868a#1?bridge=https%3A%2F%2Fv.bridge.walletconnect.org&key=be7212e692f047b39425b0fe88d805582ac29aa76ccb893d5c0cdef8845dc3c3
All the answers are from this tutorial: Connect a iOS or Android DApp to Web3 Wallet. I strongly recommend reading it.
1. "What data should be entered here?":
It's the data about your DApp, it allows the end user to recognize and decide to grant you rights when his wallet asks for it.
Here is a simple example:
private val metaData = Session.PeerMeta(
name = "nfscene",
url = "nfscene.com",
description = "nfscene WalletConnect demo"
)
2. "How can I get the wallet URL?"
You need to understand that the end-user can choose his wallet. So you can't force the wallet to be used. Knowing what Wallet the user use is not your concern as the transactions are sent through the Wallet Connect bridge. If you only want to allow the use of MetaMask you should directly use the MetaMask API.
you using 2.0.0?
it was fixed in 2.1.0.
I'm trying to authenticate an end-user in an android app written in C# (Xamarin.Android).
I decided to try and use NuGet package Google.Apis.Oauth.v2 which seems to expose an easy to use Oauth client.
LocalServerCodeReceiver.ReceiveCodeAsync throws the following:
I get System.NotSupportedException:"Failed to launch browser with https://XXX.auth.XXX.amazoncognito.com/login?response_type=token&client_id=XXX&redirect_uri=https%3A%2F%2Fwww.google.com&scope=profile%20openid%20email for authorization. See inner exception for details."
and it has an inner exception of System.ComponentModel.Win32Exception:"Cannot find the specified file"
Code:
var clientSecret = new Google.Apis.Auth.OAuth2.ClientSecrets();
clientSecret.ClientId = ...
clientSecret.ClientSecret = ...
var initializer = new Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.Initializer(
"https://XXX.auth.XXX.amazoncognito.com/login",
"https://XXX.auth.XXX.amazoncognito.com/login");
initializer.Scopes = new List<string> {"profile", "openid", "email"};
initializer.ClientSecrets = clientSecret;
var flow = new Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow(initializer);
var authCodeRequestURL = flow.CreateAuthorizationCodeRequest("https://www.google.com");
authCodeRequestURL.ResponseType = "token";
var uri = authCodeRequestURL.Build();
var cancellationTokenSource = new System.Threading.CancellationTokenSource();
var codeReceiver = new Google.Apis.Auth.OAuth2.LocalServerCodeReceiver();
var task = codeReceiver.ReceiveCodeAsync(authCodeRequestURL, cancellationTokenSource.Token);
Do I need to ask for a specific permission in the application manifest?
Instead of redirecting to www.google.com, I've heard you can redirect to an app, I'm not really sure how to do that, is it http://my_app_package_name or http://my_app_title, something else?
Is it possible not to rely on that library for launching the browser and instead get the RequestUri and start an Activity, if so how will the app become aware the end-user completed the SignIn process and how will the app retrieve the token?
Sorry, but Google.Apis.Oauth.v2 does not support Xamarin, and there's no simple way to get it working.
Unfortunately no Google.Apis.* packages currently support Xamarin.
You might find the Xamarin.Auth package does what you want?
I've figured out how to redirect to an app after authentication in the browser completes.
It's called a "Deep Link" and it's documented at enter link description here, essentially you need to declare an IntentFilter on your Activity, which registers with the Android OS that if someone clicks or an page redirects to a specific URI, your app gets called. The token that's appended to the URI can then be read inside your app.
With normal installed apps it's possible to use the technique of Deep Linking in order to not only open a specific application from an URL but also to redirect it to a specific section/function such as a specific Facebook post or specific coordinates on a map.
Since I've read that with Instant Apps this won't be possible because links already point to the specific module to download and run, how would it be possible to access not only the said module but also pass it some parameters?
For example:
This is the link from which the view-only module of my map application will be downloaded: "www.myinstantappexample.com/onlyviewmap"
If I want it to point to a specific set of coordinates how would the link be composed?
Will it be like this: "www.myinstantappexample.com/onlyviewmap/?x=0.000&y=0.000" ?
From what I've been able to find google doesn't cover this aspect and I really can't wrap my head around it.
If I want it to point to a specific set of coordinates how would the link be composed?
It's up to you how to include any additional info in the URL. It could be via URL parameters or in the path itself. Eg.
https://www.myinstantappexample.com/location/2/user/5
https://www.myinstantappexample.com/onlyviewmap/?x=1.2&y=3.4
You then parse the URL in the receiving Activity. The Uri class includes a number of helper methods such as getQueryParameter() and getPathSegments() to make this easier.
For example, to parse this URL:
https://www.myinstantappexample.com/onlyviewmap/?x=1.2&y=3.4
You would do something like this in your Activity:
Uri uri = getIntent().getData();
String x;
String y;
if (uri != null) {
x = uri.getQueryParameter("x"); // x = "1.2"
y = uri.getQueryParameter("y"); // y = "3.4"
}
if (x != null && y != null) {
// do something interesting with x and y
}
Instant Apps and Deep Linking
Instant Apps rely on App Links to work, and App Links are just one type of deep link. So deep linking is still possible for Instant Apps, and is in fact absolutely critical to how they function. However, URI scheme deep linking (which is still very prevalent in Android apps) is not supported.
The difference between a regular app and an Instant App is that the device will only load a single Activity in response to the App Link the user clicks, instead of needing to download the full package through the Play Store. It's a more seamless experience for the user, but the underlying technology works the same way.
Passing Custom Parameters
If the user clicks an App Links-enabled URL like http://www.myinstantappexample.com/onlyviewmap/?x=0.000&y=0.000, you will get that entire string back inside the app after it opens. You'll have to parse out the x and y variables yourself, but they will be available to you. Something like this:
Uri data = this.getIntent().getData();
if (data != null && data.isHierarchical()) {
String uri = this.getIntent().getDataString();
Log.i("MyApp", "Deep link clicked " + uri);
}
You'll just need to manipulate the uri value to find what you need.
Alternative Approach to Custom Parameters
Alternatively, you can use Branch.io (full disclosure: I'm on the Branch team) to power your links. We have full support for Instant Apps, and this allows you to work with a much more friendly data format. We let you create links like this, to control every part of the behavior:
branch.link({
tags: [ 'tag1', 'tag2' ],
channel: 'facebook',
feature: 'dashboard',
stage: 'new user',
data: {
x: '0.000',
y: '0.000',
'$desktop_url': 'http://myappwebsite.com',
'$ios_url': 'http://myappwebsite.com/ios',
'$ipad_url': 'http://myappwebsite.com/ipad',
'$android_url': 'http://myappwebsite.com/android',
'$og_app_id': '12345',
'$og_title': 'My App',
'$og_description': 'My app\'s description.',
'$og_image_url': 'http://myappwebsite.com/image.png'
}
}, function(err, link) {
console.log(err, link);
});
In return you get a URL like http://myappname.app.link/iDdkwZR5hx, and then inside the app after the link is clicked, you'll get something that looks like this:
{
tags: [ 'tag1', 'tag2' ],
channel: 'facebook',
feature: 'dashboard',
stage: 'new user',
data: {
x: '0.000',
y: '0.000'
}
}
In order to do that, you have to use the "app links assistant" in
Tools->App Links Assistant
Then check your links and, in the Path selector, check that the "pathPrefix" option is selected.
Then at the bottom of the OnCreate method of your activity (which is related to the link you recently edited) add this code:
Intent appLinkIntent = getIntent();
String appLinkAction = appLinkIntent.getAction();
Uri appLinkData = appLinkIntent.getData();
// then use appLinkData.getQueryParameter("YourParameter")
You can test and debug this, using the "editConfigurations" option, just open that window and edit your instantApp module (the one launched with the Link you recently edited) and in the URL field add the URL parameters that you need. (then just run that module :D )
Hope this to be helpful.
Suggest some working examples for android titanium Twitter integration.
I already tried some sample like Birdhouse, Social java script file but with that i didn't get the required output.
i just want to post a text through my titanium android app into twitter. May I know what is the correct way to achieve my objective?
Thanks in advance
Use social_plus.js it works for both android and iOS
https://github.com/aaronksaunders/test_social
Thanks
My Problem Get Solved by the Below Code
var social = require('alloy/social').create({
consumerSecret: 'consumer-secret',
consumerKey: 'consumer-key'
});
// If not authorized, get authorization from the user
if(!social.isAuthorized()) {
social.authorize();
}
// Post a message
// Setup both callbacks for confirmation
social.share({
message: "Salut, Monde!",
success: function(e) {alert('Success!')},
error: function(e) {alert('Error!')}
});
// Deauthorize the application
social.deauthorize();
Why don't you create a intent share menu ? It allows users to send content on all installed
apps that are able to share content. (email, sms, hangout, facebook...and twitter)
var createShareMenu = function(){
var subject = 'My subject';
var text = 'My text';
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
type: "text/plain",
});
intent.putExtra(Ti.Android.EXTRA_TEXT,text);
intent.putExtra(Ti.Android.EXTRA_SUBJECT,subject);
var share = Ti.Android.createIntentChooser(intent,'Share');
return share;
};
and to show the share apps menu :
shareButton.addEventListener('click', function() {
var share = createShareMenu();
var activity = win.getActivity();
activity.startActivity(share);
});