access intent to subtitles - android

I'm trying to access the subtitle settings, so I can change them.
But I'm not managing to find a way to access these settings.
Some advice?

You can use an Intent object like this to open Caption Settings:
NOTE: Minimum API level is 19
Intent intent = new Intent(Settings.ACTION_CAPTIONING_SETTINGS);
startActivity(intent);
For example, if you have a button to open Caption Settings on click.
Button button = (Button) findViewById(R.id.btn);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(Settings.ACTION_CAPTIONING_SETTINGS);
startActivity(intent);
}
});
You can return by pressing back button on device.

Related

Is there a way to get information from the web browser in Android?

I would like to create a charity application where if the users were to press the 'Donate' button, their browser would open up a link to a 3rd-party crowdfunding website where they would donate some amount for that project (or choose to exit the app or whatever!). How do I get to know what amount they have donated (or not!) from the browser so that this data can be used for that member's stats, etc.
Yes it is possible. You can use webView
Button button = (Button) findViewById(R.id.b);
button.setOnClickListener(new View.OnClickLister()
#overide
public void onClick(View v) {
WebView mWebView=(WebView)_findViewById(R.id.webView);
mWebview .loadUrl("url for third party app");
setContentView(mWebview );
});
or you can use intent
Button button = (Button) findViewById(R.id.b);
button.setOnClickListener(new View.OnClickLister()
#overide
public void onClick(View v) {
WString url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
});

How to get and show content from url by pressing a button?

How can I get and show content from url by pressing a button in android?
The button is in xml, and I need to show display information below.
Button --> information from http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=1
My wrong code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bovalpo);
Button ButtonOne = (Button)findViewById(R.id.btn);
ButtonOne.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=1"));
startActivity(viewIntent);
}
});
Your Intent is wrong. Try using:
Intent intent = new intent(Intent.ACTION_VIEW, Uri.parse("http://www.bovalpo.com/cgi-local/xml_bcv.pl?URL=1"));
startActivity(intent);
If you want to present information from link in the same view in which you press the Button, then don't use Intent, because it gets you to another view.
What you might want to use is AsyncTask (about) that would get informations via internet in background, and then present it below button, or anywhere else on screen.
To make a web connection use:
url = new URL("http://...");
urlConnection = url.openConnection();
InputStream inputStream = urlConnection.getInputStream();
And to get web data, try code shown in this topic.
Hope this helps.

Android link to wireless & Network Settings

Hi I'm making an App that checks internet connection, if it's not connected it goes to an activity that has an error message and a button that I want to link to the wireless and network settings. But I'm not sure how to do it, can anyone help me ?
Here's what I've got so far.
public class NetworkActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.networkact);
Button settings = (Button) findViewById(R.id.btn_settings);
// Listening to button event
settings.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// Starting a new Intent
Intent gotoSettings = new Intent(getApplicationContext(),
HomeActivity.class);
startActivity(gotoSettings);
}
});
}
}
At the moment it goes to another activity but I want it to go to the wireless & network settings.
I believe, what you want is this:
btn = (Button)this.findViewById(R.id.ButtonNet);
btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent=new Intent(Settings.ACTION_WIRELESS_SETTINGS);
startActivity(intent);
}
});
If you use Settings.ACTION_SETTINGS then user can go in both settings mobile network and wifi.
you can use this code for open page mobile network
startActivity(new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS));

Android: Image button as a hyperlink, phone call, map directions?

I have a simple app that I'm putting together for my company. I have 4 buttons that I've created but can't seem to get them to link correctly. One button should open our mobile site, another button to call us, another button to map to us, and the final button linked to our "News" site. Any help would be greatly appreciated!
On your buttons, you should set OnClickListener, and to do some required actions you could see the example below:
To Open a Map with Certain Location
mapButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + your-location-geo-address));
startActivity(i);
}
});
To call certain number
callButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + telephone-number));
startActivity(i);
}
});
To open a website
linkButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(website-address));
startActivity(i);
}
});
Change "location-address", "telephone-number", and "website-address" with your own String value.
I hope this helps.
anmustangs answer is very good, but one thing I would like to add for the button you are making for a link to your site, where anmustangs wrote (website-address) instead of just typing in a site, it needs to put formatted correctly. For example, you can use "http://www.google.com" and yes you do need to use the quotation marks I put in there. I know I am years late to this thread but who knows who my post may help.

How can ImageView link to web page?

is it possible to make an imageview link to a web page such that when user taps on the image, it takes them to a web page?
Just add a click listener to the image to open an URL:
ImageView img = (ImageView)findViewById(R.id.foo_bar);
img.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://casidiablo.net"));
startActivity(intent);
}
});
That's truly possible, at onClick handler you need to start an activity with intent specifying the uri. See How to open default browser for example.
another method we can even use is
image.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Intent redirect2=new Intent(getApplicationContext(),RedirectAct.class);
startActivity(redirect2);
}
});

Categories

Resources