Wednesday, 26 September 2012

Error : Path For Project Must Have Only One Segment

Error:
 
An internal error occurred during: "Launching New_configuration".
 
Path for project must have only one segment.
 
Solution:
  • Goto Run -> Run Configuration
  • Under Android Tab > Project field
  • Click Browse Button and select project you want to run.

Problem : Package Explorer Missing In Eclipse

Initially, when I started developing an android app using eclipse, I had encountered many problems. One nice day when I started Eclipse, the Package Explorer was missing from the Eclipse screen. As, I was new to work on Eclipse environment, I had tried a lot to bring the Package Explorer back. After a bit research and try, Package Explorer appeared back on eclipse screen.
 
Given below is one way to bring missing package explorer back on screen,
 
In eclipse Go to Window > Show View > Other
"Show View" window will pop up.
 
Go to General > Project Explorer > OK
 
Note: There are many way to solve this. I had tried given above one. If there is some other short cut key or way, than do write in comment and share with us.

Tuesday, 25 September 2012

How To Import Android Sample Project Or Source Code In Eclipse

Many time simple things create big mess. Initially, when I was new to android app development using eclipse, I was unaware about "How to Import or Add Sample Project or Source Code in Eclipse". Here are the ways to import android sample project or code in eclipse. If you are new to work on eclipse, then surely you may have encountered this problem. Many new comers face this common query "How to import sample program / code in eclipse Package Explorer".
 
Given below are some best way to do so,
 
1st:
 
Copy sample project to android sample project folder.
i.e. "C:\Program Files\Android\android-sdk\samples\android-15"
 
From eclipse go to: File > New > Project.
"New Android Project" window will pop-up.
 
Select "Create project from existing sample" radio button and click Next.
 
Select Build Target i.e. Android 4 (or Target you are using) or Google APIs.
 
Select Sample project that need to open and click Finish.
 
2nd:
 
From Eclipse go to: File > Import
"Import" pop window will open.
 
General > Existing Project into Workspace.
 
Click on Browse button and select the location of sample project folder and click Ok.
 
Related Search:
 
How to add sample code in eclipse?
How to import existing Android project into Eclipse?
Eclipse "import" existing source folder?

Solved : Android Library Projects Cannot Be Launched

Android library projects cannot be launched problem while running android application on eclipse. Following error message I got,
 
Error Message: Android library projects cannot be launched.
 
When I developed my first QuoteQuiz android app and tried to Run it, I got encountered with the given error. I again checked the code, build target, build path, library and everything were proper. I cleaned the project and Run again, but still this error occurred. I google for "Android library cannot be launched" problem and found the solution, this solved my problem.
 
Solution:
 
In Eclipse , Right Click on Project from Package Explorer
Select Properties,
Select Android from Properties pop up window,
See "Is Library" check box,
If it is checked then Unchecked "Is Library" check box.
Click Apply and than OK.

Wednesday, 19 September 2012

Android Quiz Game App Source Code

Keywords: Free Android quiz game source code, Project or code to create make android based quiz game download

Note: Updated version of Android App Quiz Game source code is available at Android Quiz Game Using XmlPullParser.

In this article, I am sharing source code to create android based quiz game. One can use this code to create their own personal quiz game. It was very interesting developing a QuoteQuiz app (Search for QuoteQuiz in Google play or Androidzoom.com) for android device.

As, I was new to android development, I had developed a simple quiz game app using only activities with basic skill of coding. There are many way, depending on developer, on how to develop it. In this app, I had only used activities and Xml files. No SQLite is used to save any data. Data between activities are passed using Intent.

Given below image are a glance of QuoteQuiz app. Subscribe to our newsletter to get the source code.





QuoteQuiz is created in very simple way so that beginner can learn it easily. Check out advance version of quiz on google play under SmakAndApp publisher.

Few code snippet used in coding.

Each Activity represent as new question.


@Override
 public void onCreate(Bundle savedInstanceState)
 {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.questone);
     
        Button NextButton = (Button) findViewById(R.id.id_btn_Next1);
        NextButton.setOnClickListener(this);
       
        TextView tvScore = (TextView) findViewById(R.id.id_tv_score1);
        tvScore.setText("Score : "+ 0);
    }

  @Override
 public void onClick(View v)
 {
  // TODO Auto-generated method stub
  int cnt = 0;
  RadioButton rdb1 = (RadioButton) findViewById(R.id.id_rbtn_Quest1_1);
  RadioButton rdb2 = (RadioButton) findViewById(R.id.id_rbtn_Quest1_2);

  if(rdb1.isChecked() || rdb2.isChecked() )
  {
   if(rdb1.isChecked())
   {
    cnt++;
 
   }
  Intent i = new Intent(this,QuestTwoActivity.class);
  i.putExtra("score",cnt);
  startActivity(i);
  finish();
  }

 }

Data sent between activities is shown below:

Intent i = new Intent(this,QuestTwoActivity.class);
i.putExtra("score",cnt);
"score" is key and "cnt" is value.



cnt = getIntent().getIntExtra("score",0);

"score" is key and 0 is default value i.e. if no data is passed it will assign 0.

Friday, 31 August 2012

Passing Multiple Data Between Activities In Android

If you have problem passing data or multiple data between activities in android application, then this post will solve your doubt. In Android application development process, it is easy to call an activity from another activity using an intent. But what if needed to pass data from one activity to another activity. One can do this in different way for e.g. using file system, preferences, bundle and so on.

Let us consider one example which have two activity class:

i.e. FirstActivity.java and SecondActivity.java.

Here we need to send data from FirstActivity.java to SecondActivity.java.

In FirstActivity.java

Create an Intent to call SecondActivity.java and use putExtra(key,value) method to pass data to SecondActivity.java

int id = 1;
Intent i = new Intent(this,SecondActivity);
i = putExtra("passId",id);
startActivity(i);
finish() ;
"passId" is key and "id" is value.

In SecondActivity.java

Use getExtra(key) method to get passed data from FirstActivity.java

int id;
id = getIntent.getintExtra("passId",0)
"passId" is key and 0 is default value i.e. if no data is passed it will assign 0.
For multiple data one can also use Bundle:

Bundle: Bundle are generally used to pass data between activities. Using bundle one can pass all type of values between activities.

In FirstActivity.java

Intent i = new Intent(this, SecondActivity.class);
Bundle bundle = new Bundle();
bundle.putString("userName", "Name");
bundle.putString("userPwd", "Password");
i.putExtras(bundle);
startActivity(i);

In SecondaActivity.java

Bundle getData = getIntent().getExtras();
String name= getData .getString("userName");
String pwd= getData .getString("userPwd");

Check out example of passing data between activities at Android Quiz Game App Source Code

For more info refer link given below:

Thursday, 23 August 2012

Solved R Java File Missing In Eclipse

For the beginner, who are working on eclipse to develop android application, the big problem are error's. Likewise when I was creating android app I got stuck at one error which is more common to all developer i.e
 
R.java file missing in package explorer in eclipse.
 
I searched for the solution online and got many answer but none of worked. I then checked once again the project carefully and found the error which solved ma problem.

(click on image to enlarge)

R.java file went missing in package explorer in eclipse when  cleaned project after few changes.
 
Tried all possible solution found on web but of no use. Then checked error message on console screen and sensed the problem.

Problem with res folder. Layout XML file name validation problem. File name should be in lowercase and I used first character in uppercase.
 
After renaming the file in lower case, cleaned again project and problem solved.
 
Note: There may be other solution for this problem depending on error type.




 

About CodingAndError

Brilliant mind create Brilliant Innovative. CodingAndError blog is created by a man who dream's that "Knowledge Should Be Shared Not Sold". In this blog one can find many informative article without any cost. All content here are best to author knowledge. CodingAndError will not be responsible for any damage or harm done by any of its content.