Android, the world's most popular mobile platform

Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.

ios The world’s most advanced mobile operating system.

iOS is the world’s most advanced mobile operating system, continually redefining what people can do with a mobile device. Together, the iOS SDK and Xcode IDE make it easy for developers to create revolutionary mobile apps.

Open marketplace for distributing your apps

Google Play is the premier marketplace for selling and distributing Android apps. When you publish an app on Google Play, you reach the huge installed base of Android.

Develop apps for iPhone and iPad

Create mobile apps using the programming skills, knowledge and code that you already have. Your Delphi iOS apps will have fast native performance and better security than web-based or scripting language based apps. Full visual designer for iOS user interfaces with multiple device types, resolutions, and orientations.

Powerful development framework

Android gives you everything you need to build best-in-class app experiences. It gives you a single application model that lets you deploy your apps broadly to hundreds of millions of users across a wide range of devices—from phones to tablets and beyond.

Thursday, 18 September 2014

Using Custom Fonts in Android

Using Custom Fonts in Android
                                     


Here you are going to know that how to use external fonts in Android

1.Open Eclipse IDE.
2.Click File -> New -> Project -> Android Application Project.
3.Enter the name of the application  as openactivity and click next .
4.Make sure that you have enabled the create project in workspace.
5.Design application launcher icon and create a blank activity workspace and click finish 

Now you need to design your xml file .
Activity_main.xml
Here is the coding of activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context="com.example.androidcustomfont.MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/mobile"
        android:textSize="35sp" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:gravity="center"
        android:text="@string/And"
        android:textSize="35sp" />

</RelativeLayout>

Asset
 We are going to access the fonts using this asset folder ,create a new folder under asset and named it as fonts and copy the font you needed  inside the fonts folder as shown below.
                                               
String.xml
The string.xml file is shown below the value for the textview is passed through the string.
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">AndroidCustomFont</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="mobile">Mobileapptechnology</string>
    <string name="And">Android</string>

</resources>



MainActivity.java
Here the coding of MainActivity.java here we going to set the fonts to the textview which we copied it in the fonts folder under asset. 
package com.example.androidcustomfont;

import android.support.v7.app.ActionBarActivity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;


public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tx = (TextView)findViewById(R.id.textView1);
        TextView tx1 =(TextView)findViewById(R.id.textView2);
        Typeface tf1= Typeface.createFromAsset(getAssets(), "fonts/complex.ttf");
        tx1.setTypeface(tf1);
        Typeface tf= Typeface.createFromAsset(getAssets(), "fonts/Disguise.otf");
        tx.setTypeface(tf);
    }


    }
The typeface class specify the typeface and style of the font like 
text size and specify how the text appears in the UI.
Now Run the application in emulator you will get the output as 
shown below.
                                          

             


Opening an activity in a button click in Android

Opening an Activity in a button click in Android


                                             

In this article you are going to learn about how to open an activity using Explicit intent.

1.Open Eclipse IDE
2.Click File -> New -> Project -> Android Application Project
3.Enter the name of the application  as openactivity and click next 
4.Make sure that you have enabled the create project in workspace
5.Design application launcher icon and create a blank activity workspace and click finish 

Now you need to design your xml file ,xml file is the layout where we design our User Interface.

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
tools:context="com.mobileapptechnology.openactivity.MainActivity" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="150dp"
       android:orientation="vertical" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/download"
            android:text="" />

    </RelativeLayout>

</RelativeLayout>
In the eclipse the activity_main.xml is present  under the res/layout/activity_main.xml.

In this layout you have to place a button as shown above, i had placed a image  as the background of the button.

After this now you have create a another xml file for the second activity.
so right click on the layout folder and click new and select android xml file ,they layout folder is present under the res folder.name the new xml as secondactivity.xml
String.xml
Normally in Android application whatever the values you are going to give will be provided in a proper manner.
Hardcore values could not be used in the application
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">OpenActivity</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="hai">Hai Friends</string>

</resources>

In  this application we set the value for the text view through the string.xml only as shown above.
the string.xml is under the values folder which is under the res folder.
Secondactivity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#67C1E6"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="150dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="20sp"
            android:textColor="#FFFFFF"
            android:textStyle="italic"
            android:text="@string/hai" />

    </RelativeLayout>

</RelativeLayout>
In this layout i had placed a textview just to represent a text.in textview i mentioned the style ,size and color for it.and i give the gravity as center to place the text in the center of the screen.

MainActivity.java
Now its time to code the MainActivity as shown below
package com.mobileapptechnology.openactivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Button but1=(Button)findViewById(R.id.button1);
  TextView text=(TextView)findViewById(R.id.textView1);
  but1.setOnClickListener(new OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent i= new Intent(getApplicationContext(),SecondActivity.class);
    startActivity(i);
   }
  });
 }

 
}
In MainActivity.java i have initialized the textview and button as shown above,after that am creating a on click event for the button to set the action for the button.

Here is used the explicit intent to open an activity from an activity when a button is clicked.

Here the getApplicationContext() refers the current class that 

means it refers the main activity.and the SecondActivity.class file 


refers the SecondActivity.java which is mentioned below.Before 


coding the MainActivity  we have to create a SecondActivity it 

means we have to create a new class by right clicking the package 

under the src folder and click the new and select the class give the 

name as SecondActivity.

SecondActivity.java
package com.mobileapptechnology.openactivity;

import android.app.Activity;
import android.os.Bundle;

public class SecondActivity extends Activity{
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.secondactivity);
}
}


In this SecondActivity we are going to link the secondactivity.xml file with the SecondActivity.java here we just mentioning the layout file .It is highlighted in the above code.

After that you have mention your SecondActivity.java in Manifest file ,Because Each and every activiy which we are newly creating has to be mentioned in Manifest file .Without initializing it the application will be filled with errors.

OpenActivtyManifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mobileapptechnology.openactivity"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.mobileapptechnology.openactivity.SecondActivity"></activity>
    </application>

</manifest>
The text which is in bold represent  that the SecondActivity is mentioned in the Manifest File.by default the MainActivity is mentioned in Manifest file.
Now its time to run the application,you will get the output in your emulator as shown below .


When you click the button in the UI it will redirect you the SecondActivity as shown below.
                                                                             


         

Intents

Intent:
            1) Intent is a instant action.

                        2) Intent is a message  that is passed between the components(such as                    activity,content provider,services and content provider).
                          
                        3) Normally intents are used to pass the values between activity and to go from one activity to  another activity.

The main use of intent :

                       1)Start the service 

                       2)Launch the activity

                       3)Display a web page

                       4)Broadcast a message

                       5)Dial a  phone call

Types of Intents:
                 There are two types of intents in android ,they are 
                              
                       1)Implicit Intent

                       2)Explicit Intent



                                                                         

Implicit Intent
                 Implicit intents are used to provide the information of available components provided by the system that to be invoked.

                         For example you can use implicit intent coding  to view a webpage.
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mobileapptechnology.blogspot.com"));
startActivity(i); 
Explicit Intent 
                 Explicit intents are used to provide the external class,used to move from one activity to other activity.

                        For example you can use the following code  to move from one activity to another activity.
  1. Intent i = new Intent(getApplicationContext(), ActivityTwo.class);  
  2. startActivity(i);  
                          

Total Pageviews

Contact Form

Name

Email *

Message *