Archive for the ‘Android’ Category

22
Sep

We know about the Linnkify class in android. Have you ever wondered that we can use this same class to add a market link?
Here is a sample code for the same.


TextView txtView = (TextView) findViewById(R.id.linkme);

Pattern WordMatcher = Pattern.compile("\\b[A-Z]+[a-z0-9]+[A-Z][A-Za-z0-9]+\\b");
String MarketURL = "market://details?id=com.schogini.geeta.pack&hl=pt_PT";
Linkify.addLinks(txtView, WordMatcher, MarketURL);

, , , , ,

19
Sep

The escape character for strings used in Corona is “-”.

Consider the following example of String replacement.

local contents = “Hai-brother”

local data = string.gsub( contents, “–”, “_” )  — This code will replace the occurrence of the pattern “-” with “_” in the string contents and store the value in the data object. Here the second “-” is used as an escape character for the first “-”. Otherwise it won’t work.

Now the data object will contains the string value as follows:

“Hai_brother”

, , , , , , ,

19
Sep

Let us consider an object of string type

local contents = “Hai,,brother”

local data = string.gsub( contents, “,,”, “_” )  — This code will replace the occurrence of the pattern “,,” with “_” in the string contents and store the value in the data object.

Now the data object will contains the string value as follows:

“Hai_brother”

, , , , , , , , ,

02
Sep

The following is the equivalent of do-while loop in Corona

repeat

– body inside the loop

until (condition which should become true inorder to exit this loop)

 

This will first execute the body, then checks the condition and if the condition is false, it will loop again otherwise it will exit from the loop.

, , , , , , ,

02
Sep
local sampleArray = {}    -- initializing empty array

sampleArray[#sampleArray+1]=objecttoadd   -- Adding the object to the next index of last index of the array

#sampleArray will be returning the length of sampleArray

, , , , , , ,

31
Aug

 

Declares a security permission that can be used to limit access to specific components or features of this or other applications.

<permission android:description="string resource"
            android:icon="drawable resource"
            android:label="string resource"
            android:name="string"
            android:permissionGroup="string"
            android:protectionLevel=["normal" | "dangerous" |
                                     "signature" | "signatureOrSystem"] />

, , , , , , ,

31
Aug

 

HTTP streaming looks like this:

String url = "http://........"; // your URL here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);
mediaPlayer.prepare(); // might take long! (for buffering, etc)
mediaPlayer.start();

, , ,

31
Aug

 

android:versionCode — An integer value that represents the version of the application code, relative to other versions.

android:versionName — A string value that represents the release version of the application code, as it should be shown to users.

As with android:versionCode, the system does not use this value for any internal purpose, other than to enable applications to display it to users. Publishing services may also extract the android:versionName value for display to users.

 

Here’s an example



   
        ...
   

, , , , , , , ,

31
Aug

Beginning with API Level 8, we can allow your application to be installed on the external storage

To allow the system to install your application on the external storage, modify your manifest file to include the android:installLocation attribute in the <manifest> element, with a value of either “preferExternal” or “auto“. For example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="preferExternal"
    ... >

, , , , , ,

31
Aug

 

 

The latitude and longitude are the actual coordinates

String uri = "geo:"+ latitude + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
This will load the map activity.

, , , ,