Archive for 'Widgets'

We often do release updates to our Applications. While releasing updates there are several things to be considered.

When installed as an update to a previous version, the following scenario might Occur,

shortcuts break
widgets disappear
App can’t even be installed at all.

There are certain parts of an application that are edited only once ie) during the first time of app creation. Once you publish an app, these has to be unaltered. This helps in avoiding surprises by understanding them. Here are a few important Points,

Package name
The package name should never be changed during an update. It causes the Android System to treat the new update application as an entirely new Application.
Possible Issues – Broken Widget and Shortcuts
Developer Certificate and Key
The developer’s certificate and key must be the same as the previous issue. This causes the Signature Mismatch error and fails the new update. It doesn’t allow to install the update at all.

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

Incoming search terms:

  • linkify android example

Awesome New Palette with loads of features and widgets

The palette in the layout editor has been completely rewritten. In the following screenshot, you can see the new palette on the left:

Some things to notice:
  • The palette now contains categories
  • The palette is an “accordion control” – it will always ensure that all category headers are visible, and you can click on a header to open that category. This will close the previously open category.
  • The widgets are shown as previews (rendered as they will appear using the current theme and screen density)
  • Note also that we now have logical icons for all the widgets, so the outline view on the right looks cleaner

Read the rest of this entry

We Can Build Your App for You. Lets Get Started !