Links in Sony Smartwatch 2 - android

I want to show an image in my Sony Smarwatch Sample project. How can I add a link to an external URL? The URL has to be shown in my device not in the SmartWatch. My code is the following, with this my image is shown in the layout:
Bundle iconBundle = new Bundle();
iconBundle.putInt(Control.Intents.EXTRA_LAYOUT_REFERENCE, R.id.thumbnail);
iconBundle.putString(Control.Intents.EXTRA_DATA_URI,
ExtensionUtils.getUriString(mContext, R.drawable.thumbnail_list_item));
¿How can I add a event to this bundle? I want to go to an external url. How can I add a link to my Preference Class?

I am not totally sure I understand what you are asking, but if you want to be able to click on something on the watch and have it launch a url you can use this code:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/developer?id=Sony+Mobile+Communications"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctxt.startActivity(intent);
If you want to launch the preference settings screen for your app you can do something like this:
Intent intent = new Intent(ctxt, HelloLayoutsPreferenceActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctxt.startActivity(intent);
This should work in the Hello Layouts sample project. The context is passed in the control extension constructor so you should be able to grab it from there. Please let me know if this is not what you were asking.

Related

Android intent for display url?

for some time, I have been observing that modern android apps(Telegram) use a new way to open urls in the app. By default, the apps I have made, use ACTION_VIEW and the external browser open the url. These apps now manage that intent with a kind of in-app browser witch adapts to the same style. Any idea of what its?
sample
Those are Custom chrome tabs.In app browser.instead of using webview to open your Url, you are going to customize your chrome browser,to look alike your app.you can modify the toolbar tab color as per your app theme .You could give enter and exit animation like fragments transition.So the user wouldn't feel a big transition from your app to browser.For implementation details check this link https://developer.chrome.com/multidevice/android/customtabs
For security reasons also it could be useful,as because you are not going handle those url on you own or inside your app(there might be some security issues with JavaScript)
This is done with WebView. You will find the documentation very interesting https://developer.android.com/reference/android/webkit/WebView
This is achieved by WebView in an Activity that displays web pages. Instead of
Uri uri = Uri.parse("https://www.google.com/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
You will load the page by calling:
webviewObj.loadUrl("https://www.google.com/");
You can check the official document which describes the whole process. Basic Usage of WebView has been described in this blog which is easy to comprehend and implement.
do the following:
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
try this it helps you.

After intent to show image not all functions appear

I'm going to develop a simple app to list .jpg files and after a click call an Intent.ACTION_VIEW, below the code:
File imageFile = new File(filename);
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(imageFile), "image/jpeg");
startActivity(i);
The intent works properly, in fact in app I receive the message to select an app to show the selected image. But I noticed that after the choice, for example with Google Photos, not all function are enabled. For example the share function is not visible, has someone already noticed this behavior?
Some other details; if I choose Google Photos I only have the "Info" and "Guide and Feedback" options. If I choose gallery app (I have a Samsung Ace 3) I have only "Info" and "Set as wallpaper" options.
Note: if I open the same image directly from Google Photos all functions are enabled...
The ACTION_VIEW intent calls another application to view the content that you present, in your case a JPEG image. If there is more than on application that can handle that Intent, Android lets the user choose an app to display the image. Once the application receives the Intent, it is up to that application to display the content how it sees fit.
Basically, you have no control over what functions are available with Intent.ACTION_VIEW. If you want more control, you can create your own Activity in which you can view the image and provide whatever functions you would like.

Sharing Intent shows old extras in WhatsApp

Guys i need help i aam facing a very strange problem and I would like to hear your opinion i added a share button to share images.
I used
Intent intent = new Intent ();
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity (Intent.createChooser (intent,"Share Using...."));
and it is working perfectly except for one thing if i choose the picture to share then pressed the share button and choose to share via whatsapp or G+ the application loads and the post is created with the chosen image if i backpressed i go back to my app then if i try to share another image and choose whatsapp or g+ both keep showing the old image in the new post and here comes the strange part if i post or send the image the new image is sent to the receipent and not the old image shown in the post. .... any help would be appreciated by the way i have tried using all flags with the intent but the problem persists

You need to pass a new Intent every time you want to post a new value, or clear the current object for that matter.
Can you also elaborate on this one, i didn't quite get what you meant:
if i try to share any other image whatsapp and g+ keep showing the old image in the new post and here comes the strange part if i post or send the image the new image is sent to the receipent

Using facebook.katana aka facebook app from the code

i´m trying to achieve a solution where the app ask if facebook.katana aka facebook app is installed in your android phone, if it is installed, check if the user is logged, and if it's logged send a picture with a text (better if it is to a folder), if the user is not logged go to the facebook.katana.LoginActivity and log him, after that make the procedure.
I have this working with a Web View, but i'm interested on how to do it using the app if possible, what i got so far is the uncompiled facebook.katana in this URL where i'm testing the activities:
http://xt720.ru/miui-trans/apk-decompiled/Facebook/smali/com/facebook/katana/
I also know that an image can be attached to that app, since can start the facebook app using this:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(Intent.EXTRA_STREAM,imageUri);
emailIntent.setType("image/png");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Whatever");
startActivity(Intent.createChooser(emailIntent, "Send email using"));
This method would be great for an email, but as it says it creates a chooser, but i don't want to let that option open. So i tried something like:
Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);
Also you can use the ShareLinkActivity to add an extra to your intent like this:
intent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com/");
The problem is that i don't see how to attach the image to the katana, neither, how to add it to a folder, or how to add it through an application, of course this is much easier via facebook API for android, but like i said that's already done, i want to make it with the facebook App, i have tried, attaching the Bundle to the app as a parcelable, with the usual way it is done in the API, but not luck, this is the snippet:
Bundle params = new Bundle();
params.putByteArray("picture", bitmapdata);
params.putString("title", url);
params.putString("message","Wathever message");
and try to send the params, also tried sending only the image, but not luck, maybe i'm not using the right class (see the uncopiled facebook.katana URL) or i´m attaching in a bad way the info, it should work somehow, cause it works for ACTION_SEND, so, anybody knows how to solve any of this problems:
Attach an image to the facebook.katana
Attach an image to the facebook.katana in a folder
Attach an image to the facebook.katana as an external app
Request the log status of the user to the facebook.katana (i think this would be automatically)
Attach the picture, title, message params to the facebook.katana.
Publish as the app that opens the facebook.katana (i.e. publishin with the WebView will show "published from X app"

Android - Call default browser with and redirect to a designated url

Hi
I want to write an app to call default browser and redirect to a designated url.
Any suggestion to 1)call the default browser, 2)redirect to a designated url.
Thanks
you just want to launch an ACTION_VIEW intent with the Uri of the webpage as your data element :
Intent httpIntent = new Intent(Intent.ACTION_VIEW);
httpIntent.setData(Uri.parse("http://www.bbc.co.uk"));
startActivity(httpIntent);
To open the default browser use an Intent with the action VIEW. To tell the browser which page to load us the data-part of the Intent.
Example:
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse("http://stackoverflow.com"));
startActivity(browse);
Since this is a basic task in Android you might want to read some basics about Intents in Android.

Categories

Resources