Skip to main content

Android Beginners

HelloWorld activity

Basic description of algorithm in step by step form:
  1. Create a HelloWorld Project.
  2. It will generate some default files like HelloWorld .java, main.xml, AndroidManifest.xml, Strings.xml.
  3. The AndroidManifest.xml defines an Activity which is the entry for any android application. An application can have at least one or more activity but every activity must be declared in AndroidManifest.xml
  4. The main.xml declares the user interface in XML.
  5. The strings.xml declares the text to be displayed in application.
  6. The HelloWorld class contains onCreate() method by default which is called when the activity is first created.
  7. In onCreate() method setContentView() method gets called which sets the view to setContentView (R.layout.main) by default. Here R is resource class of android which gets created automatically and which contains various layouts of the application in the form of xmls.
Steps to Create:

1  Open Eclipse. Use the New Project Wizard and select Android Project. Give the respective project name i.e. HelloWorld
2. Then enter the following information:
Project name: HelloWorld
Build Target: Android 2.2
Application name: HelloWorld
Package name: org.demoexample.HelloWorld
Create Activity: HelloWorld
3. On Clicking Finish HelloWorld code structure is generated with the necessary Android Packages being imported along with HelloWorld.java class and public void onCreate(Bundle savedInstanceState) method.

package org.demoexample.HelloWorld;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorld extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}



Comments

Popular posts from this blog

Error: Retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

My project is going on easily but suddenly what I found below bugs when developing an app. I know it's minor bug but it may be useful to anyone. Here is the error: Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'. Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. Solution: This happens because after updates your android studio uses API 23 by default. 1) First check that your compile SDK version must match the support library's major version. If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK. Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.   2) Go to your project structure -> Properties -> and change Build tool version to...

Be aware while Posting photo from a native ShareDialog in Facebook android SDK

Add the content provider to your manifest. <provider  android:name="com.facebook.NativeAppCallContentProvider" android:authorities="com.facebook.app.NativeAppCallContentProvider{Facebook-App-Id}" android:exported="true" /> Make sure exported=true (as above) Example: <provider android:name="com.facebook.NativeAppCallContentProvider" android:authorities="com.facebook.app.NativeAppCallContentProvider123456" android:exported="true" />

How to solve "com.google.android.gsf.login" has stopped problem ?

Suggestions 1) Remove any  accounts you activated then reconnect them again.. this should fIx and refresh accounts and services. Do factory reset if it does not work. 2) settings>applications>Google Play  and deleted data and cache. Required to log back into Google Play and all worked well from then on. When logged into GP noticed that your download is ready. Interesting thing is that when you started that download previously on your way BUT wifi on and the dwnld was interrupted. I think this may have caused the error. So delete data and cache and restart. 3) You can first try to go into the settings -> accounts and manually remove and reinstall your account to see if that corrects the issue. If it does not, then something got corrupted and you will need to reflash the ROM. All the tools you will need and the ROM is in the development section and ROM sections here 4) Deleting Your accounts in setting (Accounts and sync) then adding them back in. 5) F...