Posts Tagged ‘Google’
28
Nov
local socket = require("socket")
 

–Connect to the client

local client = socket.connect("www.google.com",  80)
--Get IP and Port from client
local ip, port = client:getsockname()

–Print the ip address and port to the terminal

print("IP Address: " .. ip)
print("Port: " .. port)

, , , , , ,

18
Nov

PAPAYA

PapayaMobile was founded in 2008 by two friends, Si Shen and Qian Wenjie, who met in the Computer Science Department at Tsinghua University. Si Shen worked on the Google mobile team for 5 years before deciding to team up with Qian Wenjie to start their own social mobile gaming company together. Papaya mobile is headquartered in Beijing and has an office in Menlo Park, California.

PapayaMobile is an open mobile social network for Android focused on casual gaming and virtual currency. Papaya offers developers a fast and easy way to reach millions of users worldwide and improve their return on investment for Android game development.

Android users love Papaya because they can play multiple games and get a complete social gaming experience all in one, easy to download and use app.

Virtual currency (or in-game currency depending on environment) is used to purchase virtual goods within a variety of online communities; which include social networking websites, virtual worlds and online gaming sites.[1] A key revenue driver within social media, virtual currencies are specific within each game and are used to purchase in-game goods. Characters or avatars in virtual worlds own things within the context of the virtual world and users will collect each games’ virtual currency to purchase land, supplies and various items used to enhance their status and add points.[1] Some virtual currencies are time-based, relying upon measurement of in-game achievements in order to accrue exchangeable points.
The word virtual currency or cyber currency is also often used, in a more broad sense, to indicate electronic money, that is not contractually backed by tangible assets nor by legal tender laws, and which is not a tangible commodity itself. Examples are peer-to-peer crypto-currencies like bitcoin and the above mentioned in-game currencies that are backed by virtual goods.

, , , , , , , , , , , , , , , , , , , ,

16
Nov

Not sure why posting a check-in on Facebook is such a rare topic on Google – I would expect it to be one of the most written about and searched about topics.
Anyway after hours of Google-ing, trials using graph api and legacy REST api, this is the simplest code (my opinion) to post or do or make a check-in on Facebook.

Assuming that you have the latest Facebook PHP SDK (https://github.com/facebook/php-sdk/downloads) copy this code:
checkin.php

require("src/facebook.php");

// construct the object with your facebook app data
$facebook = new Facebook(array(
'appId'  => '[YOUR APP ID]',
'secret' => '[YOUR APP SECRET ID]',
'cookie' => true
));

try {
	// to get the id of the currently logged in user
	// if, you want you can manually set a user id here like this:
	//$uid = '[FB USER ID]';
	$uid = $facebook->getUser();

	// if you know know the access token before hand then you can set it here
	// or you can leave this line commented
	//$facebook->setAccessToken([ACCESS TOKEN FOR THIS USER - APP]);

	$api_call = array(
		'method' => 'users.hasAppPermission',
		'uid' => $uid,
		'ext_perm' => 'publish_checkins'
	);
	$can_post = $facebook->api($api_call);
	if ($can_post) {
		$facebook->api('/'.$uid.'/checkins', 'POST', array(
		'access_token' => $facebook->getAccessToken(),
		'place' => '[LOCATION ID]',
		'message' => 'I am place to check in',
		'picture' => 'http://test.com/someplace.png',
		'coordinates' => json_encode(array(
		   'latitude'  => '[LATITUDE]',
		   'longitude' => '[LONGITUDE]',
		   'tags' => '[A LIST OF TAGS TO USE FOR THIS CHECKIN]'))
		));
		echo 'You are checked in';
	} else {
		die('Permissions required!');
	}
} catch (Exception $e){
	// No user found - ask the person to login
	$login_url = $facebook->getLoginUrl();
	header("Location: ".$login_url);
}

Some points to note:

  • If, you are setting an access token manually, then ensure that the user has allowed publish_checkins permission.
  • You must use a valid Location ID that has a page on Facebook
  • The URL to this script must be in the app site Url. For example, if your Facebook app’s site URL is http://myworld.com/ then this script should be somewhere inside http:/myworld.com

, , , , , , , , , , , , , , , , , , ,

30
Oct

Often, you want to supply some criteria to search on. You can do this by supplying this information as part of the Intent’s extras. The ACTION_WEB_SEARCH Intent specifically uses the SearchManager.QUERY extra field for the search criteria. For example, to perform the Google search on pygmy goats, you configure the SearchManager.QUERY extra and launch the Browser as follows:

 

Intent search = new Intent(Intent.ACTION_WEB_SEARCH);  

search.putExtra(SearchManager.QUERY, “iPhone 4S”);  

startActivity(search);  

 
 

, , , , , , , , ,

30
Sep

you can verify the internet connection using the following code:

local http = require("socket.http")
local ltn12 = require("ltn12")

if http.request( "http://www.google.com" ) == nil then

        local function onCloseApp( event )
        if "clicked" == event.action then
                os.exit()
        end
        end

        native.showAlert( "Alert", "An internet connection is required to use this application.", { "Exit" }, onCloseApp )
end

Source:http://developer.anscamobile.com/code/check-internet-connection

, , ,

18
Aug

The following html script will load a form, you have to enter latitude and longitude in the text box and submit. Tha’t it.

<html><head><title>GoogleMap</title>
<body>
<form method=”GET” action=”http://maps.google.com/maps”>
Enter Latitude,longitude:
<input type=”hidden” name=”f” value=”q” />
<input type=”hidden” name=”source” value=”s_q” />
<input type=”hidden” name=”hl” value=”en” />
<input type=”hidden” name=”geocode” value=”" />
<input type=”text” size=”40″ name=”q” value=”38.12345,22.12345″ />
<input type=”hidden” name=”ie” value=”UTF8″ />
<input type=”hidden” name=”output” value=”embed” />
<input type=”submit” value=”submit” />
<br />(Use comma to separate values)
</form>
</body>
</html>

, , , , , , , , , , ,

30
Jun

EditText editText = (EditText) findViewById(R.id.textId);
int pos = editText.getText().length();
editText.setSelection(pos);

, , , , , , , , , , , ,

31
May

The latest version of Android is codenamed Ice Cream Sandwich, which is doing the rounds for months, has been confirmed on the Android Open Source Project’s issues forum. Though its not officially announced, Eric Schmidt said at the Mobile World Congress in February that the next major update of Android would be a dessert starting with the letter “i” which will integrate the features of Android 2.3 Gingerbread and Android 3.0 Honeycomb. The name leak was made by Android developer, Romain Guy on a support forum for Google Mobile while responding to a Google Code issue on the Android project hub where he noted that the issue will be fixed in “Ice Cream Sandwich”. The new version of Android mobile operating system is rumored to complete and will be unveiled along with Google TV at the Google I/O conference next week.

, , , , , , , , , , , , , , ,

31
May

Webview is primarily used for loading a html content  in our application.

loadUrl is  the prime method to load a particular webpage to webview.

Hence make use of the snippet to load a page.

public class WebViewExample extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.co.in/");

webView.setWebViewClient(new HelloWebViewClient());

}
}

But the above method loads the browser instead of opening the webpage inside the application.

To overcome this difficulty we should use the method shouldOverrideUrlLoading() along with webview and url string.

Now the application opens the web page inside the application itself.

public class HelloWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}

, , , , , , , , , , ,

26
May

Linkify property of Android TextView allows users to click on links, phone numbers, html..etc, without coding for it, by using listeners.

An attribute called

android:autoLink

does this trick.

xml Code:

<!--?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<!-- Four TextView widgets, each one displaying text containing links. -->

<!-- text1 automatically linkifies things like URLs and phone numbers. -->

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoLink="all"
android:text="@string/link_text_auto"
/>

<!– text2 uses a string resource containing explicit tags to specify links. –>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/link_text_manual"
/>

<!-- text3 builds the text in the Java code using HTML. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text3"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

<!-- text4 builds the text in the Java code without using HTML. -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text4"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

</LinearLayout>

 

String Value:

<string name=”link_text_manual”>

text2: This is some other
text, with a <a href=”http://www.google.com”>link</a> specified
via an <;a> tag.  Use a \”tel:\” URL
to <a href=”tel:4155551212″>dial a phone number</a>.
</string>

Java Code:

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.widget.TextView;

public class Link extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.link);

// text1 shows the android:autoLink property, which
// automatically linkifies things like URLs and phone numbers
// found in the text.  No java code is needed to make this
// work.

// text2 has links specified by putting  tags in the string
// resource.  By default these links will appear but not
// respond to user input.  To make them active, you need to
// call setMovementMethod() on the TextView object.

TextView t2 = (TextView) findViewById(R.id.text2);
t2.setMovementMethod(LinkMovementMethod.getInstance());

 

 

 

// text3 shows creating text with links from HTML in the Java
// code, rather than from a string resource.  Note that for a
// fixed string, using a (localizable) resource as shown above
// is usually a better way to go; this example is intended to
// illustrate how you might display text that came from a
// dynamic source (eg, the network).

TextView t3 = (TextView) findViewById(R.id.text3);
t3.setText(
Html.fromHtml(
"<b>text3:</b>  Text with a " +
"<a href=\"http://www.google.com\">link</a> " +
"created in the Java source code using HTML."));
t3.setMovementMethod(LinkMovementMethod.getInstance());

// text4 illustrates constructing a styled string containing a
// link without using HTML at all.  Again, for a fixed string
// you should probably be using a string resource, not a
// hardcoded value.

SpannableString ss = new SpannableString(
"text4: Click here to dial the phone.");

ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 6,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new URLSpan("tel:4155551212"), 13, 17,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

TextView t4 = (TextView) findViewById(R.id.text4);
t4.setText(ss);
t4.setMovementMethod(LinkMovementMethod.getInstance());
}
}

ScreenShot:

Linkify android 3.0

Linkify android 3.0

, , , , , , , , , , , , , , , , , , , ,