Showing posts with label get. Show all posts
Showing posts with label get. Show all posts

Get WiFi link speed and frequency

| 0 comments |
Example show how to get WiFi link speed and frequency:


When WiFi OFF


package com.blogspot.android_er.androidwifispeedfrequency;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TextView textInfo = (TextView)findViewById(R.id.info);
TextView textSpeed = (TextView)findViewById(R.id.speed);
TextView textFreq = (TextView)findViewById(R.id.frequency);

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if(wifiManager!=null){
textInfo.setText(wifiManager.toString());
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
textSpeed.setText("Link Speed: " + wifiInfo.getLinkSpeed() + wifiInfo.LINK_SPEED_UNITS);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
textFreq.setText("Freuency: " + wifiInfo.getFrequency() + wifiInfo.FREQUENCY_UNITS);
}
}else{
textInfo.setText("wifiManager == null!");
}
}
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

android_layout_width="match_parent"
android_layout_height="match_parent"
android_padding="16dp"
android_orientation="vertical"
tools_context="com.blogspot.android_er.androidwifispeedfrequency.MainActivity">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold" />

<TextView
android_id="@+id/info"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textStyle="italic"/>
<TextView
android_id="@+id/speed"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textStyle="bold"
android_textSize="30dp"/>
<TextView
android_id="@+id/frequency"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textStyle="bold"
android_textSize="30dp"/>

</LinearLayout>



uses-permission of "android.permission.ACCESS_WIFI_STATE" is needed in AndroidManifest.xml.

Read More..

Get Ready for the Chrome Dev Summit 2015

| 0 comments |

Posted by Paul Kinlan, Chrome Developer Relations

The Chrome Dev Summit is almost here! We’ll kick off live from Mountain View, California at 9:00AM PT this coming Tuesday, November 17th. To get the most out of the event, make sure to check out the speaker list and talk schedule on our site.

Can’t join us in person? Don’t worry, we’ve got you covered! You can tune into the summit live on developer.chrome.com/devsummit. We will stream the keynote and all sessions over the course of the event. If you want us to send you a reminder to tune into the livestream, sign up here. We’ll also be publishing all of the talks as videos on the Chrome Developers YouTube Channel.

We’re looking forward to seeing you in person or remotely on Tuesday. Don’t forget to join the social conversations at #ChromeDevSummit!

Read More..

Get ISO country code for the given latitude longitude using GeoNames Java Client

| 0 comments |
Last example show "Get ISO country code for the given latitude/longitude, using GeoNames Web Service, using HttpURLConnection". GeoNames provide Java Client for GeoNames Webservices to help developers to easily access the geonames web services with java. This post show how to use it in Android.

To use Java Client for GeoNames Webservices in you Android Studio project, you have to download both geonames-1.1.13.jar and jdom-1.0.jar to your local machine. Visit http://www.geonames.org/source-code/ to download.

Then you have to add the JAR modules in your Android Studio Project, refer to the video.


dependencies of :geonames-1.1.13 and :jdom-1.0 will be added in your build.gradle.

Example to get ISO country code for the given latitude/longitude, using GeoNames Java Client:


MainActivity.java
package com.blogspot.android_er.androidgeonames;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import org.geonames.GeoNamesException;
import org.geonames.WebService;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {

EditText latText;
EditText lonText;
Button btnFind;
TextView textResult;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
latText = (EditText)findViewById(R.id.latText);
lonText = (EditText)findViewById(R.id.lonText);
btnFind = (Button)findViewById(R.id.find);
textResult = (TextView)findViewById(R.id.result);

btnFind.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String strLat = latText.getText().toString();
String strLon = lonText.getText().toString();

boolean parsable = true;
Double lat = null, lon = null;

try{
lat = Double.parseDouble(strLat);
}catch (NumberFormatException ex){
parsable = false;
Toast.makeText(MainActivity.this,
"Latitude does not contain a parsable double",
Toast.LENGTH_LONG).show();
}

try{
lon = Double.parseDouble(strLon);
}catch (NumberFormatException ex){
parsable = false;
Toast.makeText(MainActivity.this,
"Longitude does not contain a parsable double",
Toast.LENGTH_LONG).show();
}

if(parsable){
new GeoNamesTask(textResult).execute(lat, lon);
}

}
});
}

private class GeoNamesTask extends AsyncTask<Double, Void, String> {
TextView tResult;

public GeoNamesTask(TextView vResult){
tResult = vResult;
tResult.setText("");
}

@Override
protected String doInBackground(Double... params) {
return queryGeoNames_countryCode(params[0], params[1]);
}

@Override
protected void onPostExecute(String s) {
tResult.setText(s);
}

private String queryGeoNames_countryCode(double latitude, double longitude){
String queryResult = "";

/*
Do not use the demo account for your app or your tests.
It is only meant for the sample links on the documentation pages.
Create your own account instead.
*/
WebService.setUserName("demo");

try {
queryResult = "CountryCode: " + WebService.countryCode(latitude, longitude);
} catch (IOException e) {
e.printStackTrace();
queryResult = e.getMessage();
} catch (GeoNamesException e) {
e.printStackTrace();
queryResult = e.getMessage();
}

return queryResult;
}
}
}


layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout


android_layout_width="match_parent"
android_layout_height="match_parent"
android_padding="16dp"
android_orientation="vertical"
tools_context=".MainActivity">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold" />

<EditText
android_id="@+id/latText"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_inputType="numberSigned|numberDecimal"
android_hint="Latitude"
android_text="47.03"/>

<EditText
android_id="@+id/lonText"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_inputType="numberSigned|numberDecimal"
android_hint="Longitude"
android_text="10.2"/>

<Button
android_id="@+id/find"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_text="find"/>

<TextView
android_id="@+id/result"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_textSize="28dp"
android_textStyle="bold"/>
</LinearLayout>


Permission of "android.permission.INTERNET" is needed in AndroidManifest.xml
 <uses-permission android_name="android.permission.INTERNET"/>




Read More..

I can get another if I break it Announcing Noto Nastaliq Urdu

| 0 comments |
Today, we are excited to release an early version of Noto Nastaliq Urdu.

Nastaliq’s rich typographic tradition presents particular challenges to computerized typography. We’ve been working over a year to solve technical and design issues for an Urdu Nastaliq (aka Nastaleeq) font. This early version is by no means complete and perfect. We expect to work closely with the community to incorporate comments and suggestions.

This preview font can be downloaded from the Noto homepage or the Noto repository, and is also available as a webfont on Google Fonts Early Access.

This is a sample web page to showcase Noto Nastaliq Urdu as a webfont. Go ahead open it. If your browser renders it correctly, you will see something like this:


Text in the image is from a poem by Urdu poet Mirza Ghalib. It means “I can get another if I break it / so a clay cup trumps a grail.” This font can be challenging to the current generation of browsers and font renderers. It partially broke a few of them; we have been working with browser manufacturers to fix all those issues.

We are looking forward to your feedback and bug reports. Please contact us through https://code.google.com/p/noto/issues/entry. Known issues can be found here.

Posted by Behdad Esfahbod, Software Engineer, Fonts & Text Rendering, Google Internationalization Engineering
Read More..

Get ISO country code for the given latitude longitude using GeoNames Web Service using HttpURLConnection

| 0 comments |
The GeoNames geographical database covers all countries and contains over eight million placenames that are available for download free of charge. We can get the iso country code for any given latitude/longitude, using GeoNames webservices; api.geonames.org/countryCode?



CountryCode / reverse geocoding

The iso country code of any given point.
Webservice Type : REST 
Url : api.geonames.org/countryCode?
Parameters : lat,lng, type, lang, radius (buffer in km for closest country in coastal areas, a positive buffer expands the positiv area whereas a negative buffer reduces it);
Result : returns the iso country code for the given latitude/longitude
With the parameter type=xml this service returns an xml document with iso country code and country name. The optional parameter lang can be used to specify the language the country name should be in. JSON output is produced with type=JSON
Example http://api.geonames.org/countryCode?lat=47.03&lng=10.2&username=demo 

Important:

  • Do not use the demo account for your app or your tests. It is only meant for the sample links on the documentation pages. Create your own account instead.
  • The parameter username needs to be passed with each request. The username for your application can be registered here. You will then receive an email with a confirmation link and after you have confirmed the email you can enable your account for the webservice on your account page
  • Dont forget to url encode string parameters containing special characters or spaces. (Faq entry on url encoding)
  • ...
read details: http://www.geonames.org/export/web-services.html


Its a example to get the ISO country code of user entered latitude/longitude.


MainActivity.java
package com.blogspot.android_er.androidgeonames;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainActivity extends AppCompatActivity {

EditText latText;
EditText lonText;
Button btnFind;
TextView textResult;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
latText = (EditText)findViewById(R.id.latText);
lonText = (EditText)findViewById(R.id.lonText);
btnFind = (Button)findViewById(R.id.find);
textResult = (TextView)findViewById(R.id.result);

btnFind.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String strLat = latText.getText().toString();
String strLon = lonText.getText().toString();

new GeoNamesTask(textResult).execute(strLat, strLon);
}
});
}

private class GeoNamesTask extends AsyncTask<String, Void, String> {
TextView tResult;

public GeoNamesTask(TextView vResult){
tResult = vResult;
tResult.setText("");
}

@Override
protected String doInBackground(String... params) {

/*
Do not use the demo account for your app or your tests.
It is only meant for the sample links on the documentation pages.
Create your own account instead.
*/
String queryString =
"http://api.geonames.org/countryCode?lat=" + params[0]
+ "&lng=" + params[1] + "&username=demo";

String s = "";
try {
s = sendQuery(queryString);
} catch (IOException e) {
e.printStackTrace();
s = e.getMessage();
}
return s;
}

@Override
protected void onPostExecute(String s) {
tResult.setText(s);
}


private String sendQuery(String query) throws IOException {
String result = "";

URL searchURL = new URL(query);

HttpURLConnection httpURLConnection = (HttpURLConnection)searchURL.openConnection();
if(httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK){
InputStreamReader inputStreamReader = new InputStreamReader(httpURLConnection.getInputStream());
BufferedReader bufferedReader = new BufferedReader(
inputStreamReader,
8192);

String line = null;
while((line = bufferedReader.readLine()) != null){
result += line;
}

bufferedReader.close();
}

return result;
}
}
}


layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout


android_layout_width="match_parent"
android_layout_height="match_parent"
android_padding="16dp"
android_orientation="vertical"
tools_context=".MainActivity">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold" />

<EditText
android_id="@+id/latText"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_inputType="numberSigned|numberDecimal"
android_hint="Latitude"
android_text="47.03"/>

<EditText
android_id="@+id/lonText"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_inputType="numberSigned|numberDecimal"
android_hint="Longitude"
android_text="10.2"/>

<Button
android_id="@+id/find"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_text="find"/>

<TextView
android_id="@+id/result"
android_layout_width="match_parent"
android_layout_height="wrap_content" />
</LinearLayout>


Permission of "android.permission.INTERNET" is needed in AndroidManifest.xml
 <uses-permission android_name="android.permission.INTERNET"/>

Next:
GeoNames also provide Java Client for GeoNames Webservices to help developers to easily access the geonames web services with java. Next post "Get ISO country code for the given latitude/longitude, using GeoNames Java Client" show how to use it in Android Studio project.

Related:
- Find addresses of given latitude and longitude using android.location.Geocoder

Read More..

Get Ready for the Polymer Summit 2015

| 0 comments |

Posted by Taylor Savage, Product Manager, Polymer


The Polymer Summit is almost here! We’ll officially kick off live from Amsterdam at 9:00AM GMT+2 this coming Tuesday, September 15th. To get the most out of the event, make sure to check out the speaker list and talk schedule on our site.

Can’t join us in person? Don’t worry, we’ve got you covered! You can tune into the summit live on www.polymer-project.org/summit. We will stream the keynote and all sessions over the course of the event. If you want us to send you a reminder to tune into the livestream, sign up here. We’ll also be publishing all of the talks as videos on the Chrome Developers YouTube Channel.

We’re looking forward to seeing you in person or remotely on Tuesday. Don’t forget to join the social conversations at #PolymerSummit!

Read More..

Get ready for even more material design

| 0 comments |

Posted by Monica Bagagem, Developer Marketing

Google I/O 2015 starts tomorrow, and, like last year, we’ve got an exciting lineup of design-focused content for both developers and designers to experience in-person and online. Just a year ago, we announced material design - a system for cross-platform visual, motion, and interaction design. This year at I/O, we’ll see how material has been adopted and implemented by the community, and our approach on design across our platforms.

Sessions

At 4PM PDT on Thursday, May 28, join Matias Duarte’s “Material Now” session to recap where we’ve been and get a sneak peek of where we’re going with design at Google. We’ll be recognizing some of the phenomenal material design work from across the community, so definitely tune in if you’re an Android developer or designer. For more details, check Matias’ post on Google+.

The session will be live streamed so you can follow along in real-time even if you’re not at Moscone. Recordings will also be available shortly after on the I/O website.

Add Design Sessions to your I/O schedule

Design Sandbox

We’ve dedicated an entire section of Moscone West to design-related programming, including one-on-one and group UX reviews with members of the material design team. Appointments will be on a first-come, first-serve basis, but well also have Google designers on hand for more casual questions.

Add Material Design Reviews to your I/O schedule

Sandbox Talks

Google designers and engineers will host several deep-dive, 20 minute tech talks in a breakout area within the Design Sandbox on Level 2. The space has been designed to facilitate conversation and discussion with small audiences, so come prepared with questions! We’ll be covering a range of topics such as cross-platform and responsive design, designing for platforms like Google Cast and Android Auto, and how to adapt material design to your brand. As an added bonus, most Sandbox Talks will take place twice throughout the conference giving you more flexibility to adjust your schedule.

Add Design Sandbox Talks to your I/O schedule

Explore the full Google I/O schedule here.

Be sure to follow +GoogleDesign and @GoogleDesign, where we’ll be posting design-related announcements throughout the conference. You can also follow and join the general conversation about I/O at #io15. See you tomorrow!

Read More..

Get your students on the same web page instantly

| 0 comments |
Posted by Catherine Davis, former 4th grade teacher and Director of Academic Technology at Pilgrim School

(Cross-posted on the Google for Education Blog.)




Editors note: Today we’re launching a new Chrome extension, Share to Classroom, which solves a big pain point for teachers: getting all students to the same website during class. The Share to Classroom extension works on any laptop, including Chromebooks, Macs and PCs. Catherine Davis, former 4th grade teacher and Director of Academic Technology at Pilgrim School, piloted the Classroom extension with Mrs. Shorkey’s 3rd grade class, and here she describes her experience using this new extension and the impact on her students.







Sharing a website with my students is a great way to get them engaged. When we studied South America, I shared a video of Tierra del Fuego, and my students were able to view the coast, hear the wind and see the waves soar. But getting a class full of 4th graders on the same web page is a huge challenge. I typically write the URL on the board, then walk around to help each student who misses a capital or underscore or backslash. My students get frustrated, I get frustrated, and before I know it 10 minutes of precious teaching time is lost.

So I was thrilled to pilot the Share to Classroom extension. With the extension I can open a website and “push” it to my Google Classroom students, so the page opens immediately on all their devices. Our 3rd graders gasped when we tried it – the webpage instantaneously popped up on all of their screens.
The new extension lets me engage my students and help them drive their own learning on 1:1 devices at our school. When our 3rd graders were studying Native American culture, I pushed a website to the class so they could research traditional clothing and food. The students aren’t locked to the page I send, and one student navigated from there to an even better site. With the Classroom extension, the student was able to push the new site to me, and I reviewed and pushed to the entire class. She had a boost of confidence when her discovery drove class discussion.
Using the extension also lets me think on my feet. When discussing pioneers, a brave student raised his hand and asked “What’s a stage coach?” I realized my students hadn’t been exposed to the term. I immediately pulled up a definition and video and pushed it to the class. I also saved the webpage as a draft to post to my other Classroom students later. I could have projected on a screen, but the intimacy of having the webpage on each device allows students to explore on their own, hear clearly and watch repeatedly. It also levels the playing field for ELL and students of different backgrounds so everyone starts literally on the same page.

As teachers, we never feel we have enough time to do everything we want with our students. The new Share to Classroom extension gives us back those few minutes it takes to get students to the same place and makes learning about investigating, not about navigating.

*Note: Google Apps admins can install the extension for their entire domain so that it’s easiest for teachers and students to get started. Teachers and students both need the extension in order to push web pages to each other.
Read More..

Lumia 800 and 710 users to get software update on June 27

| 0 comments |
Yesterday, much to the disappointment of the existing Lumia owners, it was announced that they wont be getting the Windows Phone 8 update but instead the stripped down Windows Phone 7.8 update, that brings the new homescreen from Windows Phone 8, among other minor features.



However, Nokia promised to continue support for the Lumia devices and regular updates that add some unique features to the Lumia phones.

Now Nokia has announced that the Lumia 800 and Lumia 710 will be getting another softwareupdate on June 27. This update will bring features such as internet sharing, flip-to-silence and media streaming.

All of this in addition to some other great features that Nokia announced for the Lumia range, such as the camera enhancements, contact sharing, data counter, DLNA and exclusive Zynga games such as Words With Friends and Draw Something.

If you are a current Nokia Lumia user, do let us know what you feel about these updates.

Source
Read More..