Question about Google Android

2 Answers

StartActivity fails to launch class called

I have a HelloAndroid.java and a find.java. I am trying to pass control to find.java when the Find button is clicked. When findx is executed the application aborts with this message: ...application has stopped unexpectedly. The activity find is defined in Manifest.xml. Any other code I put into findx executes without a problem.

Here is the code:

btnfind = (Button)findViewById(R.id.find);
btnfind.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ findx(); }});

private void findx()
{

Intent i = new Intent(this,find.class);
startActivity(i);
}

Manifest.xml

package="com.android.hello"
android:versionCode="1"
android:versionName="1.0.0">

android:label="@string/app_name">







Posted by on

2 Answers

  • Level 1:

    An expert who has achieved level 1.

    Mayor:

    An expert whose answer got voted for 2 times.

  • Contributor
  • 1 Answer

This example is working try it.

Forwarding.java
----------------------

package com.example.android.apis.graphics;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Forwarding extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.forwarding);
Button goButton = (Button)findViewById(R.id.go);
goButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
Intent intent = new Intent();
intent.setClass(Forwarding.this, ForwardTarget.class);
startActivity(intent);
finish();
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
});
}
}


ForwardTarget
--------------------

package com.example.android.apis.graphics;
import android.app.Activity;
import android.os.Bundle;
public class ForwardTarget extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

setContentView(R.layout.forward_target);
}
}



AndroidManifest.xml
-----------------------------

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.apis.graphics"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Forwarding"
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=".ForwardTarget"/>
</application>
</manifest>


forwarding.xml
---------------------

<?xml version="1.0" encoding="utf-8" ?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="4dip"
android:gravity="center_horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="0"
android:paddingBottom="4dip" android:text="forwarding" />
<Button android:id="@+id/go" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="go">
<requestFocus />
</Button>
</LinearLayout>

forward_target.xml
---------------------------

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="4dip"
android:gravity="center_horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="0"
android:text="forward_target" />
</LinearLayout>


Posted on Mar 02, 2009

  • Level 1:

    An expert who has achieved level 1.

    Mayor:

    An expert whose answer got voted for 2 times.

  • Contributor
  • 1 Answer

I think your problem is in AndroidMainfest.xml

Eclipse did't add this line automaticly (for me):
<activity android:name=".ForwardTarget"/>

Posted on Mar 13, 2009

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Minecraft Odd Popup


Solution should be to re-install java

http://java.com/en/download/manual.jsp download from this site, 32 or 64bit version depending on your setup.

Dec 13, 2013 | Microsoft Windows Vista Home Basic Edition...

1 Answer

Java download failed


what error do u get when u r lunching internet explorer or firefox? try to download in install google chrome and try

Dec 02, 2011 | Microsoft Windows XP Home Edition

1 Answer

I not insttal java in my computer


Just go to sun.com
download jdk latest version..okay
them install it ...
after it go system properties then advanced then environment variable then

create new named path and write value "C:\Program Files\Java\jdk1.6.0\bin;"

now set your class path as named class path and value
"C:\Program Files\Java\jdk1.6.0\bin;.;"


then your java will install.

To check whether java is installed ...open notepad and write javac and hit enter .....if it gives many options then your java is installed......okay

Aug 19, 2010 | Operating Systems

1 Answer

TO RUN JAVA HOW TO CONFIGURE INTERNET CONNECTION


if you use IE you make tips:
1. Launch your Internet Explorer browser.
2. Click the "Tools" button on the top menu, then scroll down and click "Internet Options."
3. Click the "Security" tab and click "Custom Level." Scroll down and click "Enable" under "Scripting of Java Applets."
4. Click "OK" to save the changes and "OK" again to close the Internet Options window.

If you use Mozilla Firefox :
1. Launch your Mozilla Firefox web browser and click the "Tools" button.
2. Scroll down the Tools menu and click "Options." Click the "Content" tab and place a check on "Enable JavaScript" check-box.
3. Click "OK" to save the changes and close the "Options" window.

if you use Opera :
1. Launch your Opera web browser and click the "Tools" button.
Step 2Scroll down and click "Preferences." Click the "Content" button on the "Advanced" tab and click "Enable JavaScript."
3.Click "OK" to save the changes. Click the "Back" button on the web browser to return to the previous page and click "Reload" to run the JavaScript.good luck

Apr 27, 2010 | Sun Java Desktop System

1 Answer

HelloAndoird problem with emulator


Try using the avd (android virtual device) manager. Create a new virtual device. Make sure you use the correct API level that you are building your app for. API level 4 is for Android 1.6 (Donut), which would support most shipping phones.

Feb 23, 2010 | Google Android

2 Answers

Hi tryed to download javameantime, error code 25099 connot unzipp core files, how do i corect the problem,


WORKAROUND

Step 1 : Completely delete content of the following directory: C:\Program Files\Java\jre6\ (or alternate directory if you chose a non-default install location)

Step 2 : If Step 1 has permission issues due to files being locked or in use, restart your system

Step 3 : Now, completely delete content of the following directory: C:\Program Files\Java\jre6\

Step 4 : Download and install Java.
  1. Go to Java.com
  2. Click on the Free Java Download button, and start the installation process.

Sep 17, 2009 | Microsoft Windows XP Professional With...

1 Answer

I need a complete workingsource code written in


This is a simple source code for Simple calculator in Java using RMI
//mathServer//
import java.rmi.*;
import java.rmi.Naming.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
import java.util.*;
interface mathInterface extends Remote
{
public int add(int a,int b) throws RemoteException;
public int subt(int a,int b) throws RemoteException;
public int mult(int a,int b) throws RemoteException;
public int div(int a,int b) throws RemoteException;
}
public class mathServer extends UnicastRemoteObject implements
mathInterface
{
public mathServer() throws RemoteException
{
System.out.println("Initializing Server");
}
public int add(int a,int b)
{
return(a+b);
}
public int subt(int a,int b)
{
return(a-b);
}
public int mult(int a,int b)
{
return(a*b);
}
public int div(int a,int b)
{
return(a/b);
}
public static void main(String args[])
{
try
{
mathServer ms=new mathServer();
java.rmi.Naming.rebind("MathServ",ms);
System.out.println("Server Ready");
}
catch(RemoteException RE)
{
System.out.println("Remote Server Error:"+ RE.getMessage());
System.exit(0);
}
catch(MalformedURLException ME)
{
System.out.println("Invalid URL!!");
}
}
}

//mathClient//
import java.rmi.*;
import java.rmi.registry.*;
import java.awt.*;
import java.awt.event.*;
public class mathClient extends Frame implements ActionListener
{
Button B1=new Button("Sum");
Button B2=new Button("Subtract");
Button B3=new Button("Multiply");
Button B4=new Button("Divide");
Label l1=new Label("Number 1");
Label l2=new Label("Number 2");
Label l3=new Label("Result");
TextField t1=new TextField(20);
TextField t2=new TextField(20);
TextField t3=new TextField(20);
public mathClient()
{
super("Calculator");
setLayout(null);
l1.setBounds(20,50,55,25);
add(l1);
l2.setBounds(20,100,55,25);
add(l2);
l3.setBounds(20,150,55,25);
add(l3);
t1.setBounds(150,50,100,25);
add(t1);
t2.setBounds(150,100,100,25);
add(t2);
t3.setBounds(150,150,100,25);
add(t3);
B1.setBounds(20,200,80,25);
add(B1);
B2.setBounds(100,200,80,25);
add(B2);
B3.setBounds(180,200,80,25);
add(B3);
B4.setBounds(260,200,80,25);
add(B4);
B1.addActionListener(this);
B2.addActionListener(this);
B3.addActionListener(this);
B4.addActionListener(this);
addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent AE)
{
if(AE.getSource()==B1)
{
sum();
}
else if(AE.getSource()==B2)
{
subt();
}
else if(AE.getSource()==B3)
{
mult();
}
else if(AE.getSource()==B4)
{
div();
}
}
public void sum()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.add(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void subt()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.subt(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void mult()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.mult(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void div()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.div(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public static void main(String args[])
{
mathClient MC=new mathClient();
MC.setVisible(true);
MC.setSize(600,500);
};
}

Jul 03, 2009 | Microsoft Operating Systems

1 Answer

How to write jdbc connections


http://www.jdbc-tutorial.com/

window.google_render_ad();

welcome_title_image.gif Java JDBC Tutorial Java JDBC Tutorial
The JDBC ( Java Database Connectivity) API defines interfaces and classes for writing database applications in Java by making database connections. Using JDBC you can send SQL, PL/SQL statements to almost any relational database. JDBC is a Java API for executing SQL statements and supports basic SQL functionality. It provides RDBMS access by allowing you to embed SQL inside Java code. Because Java can run on a thin client, applets embedded in Web pages can contain downloadable JDBC code to enable remote database access. You will learn how to create a table, insert values into it, query the table, retrieve results, and update the table with the help of a JDBC Program example.


window.google_render_ad();
Although JDBC was designed specifically to provide a Java interface to relational databases, you may find that you need to write Java code to access non-relational databases as well.
JDBC Architecture jdbc.jpg Java application calls the JDBC library. JDBC loads a driver which talks to the database. We can change database engines without changing database code.
JDBC Basics - Java Database Connectivity Steps Before you can create a java jdbc connection to the database, you must first import the
java.sql package.
import java.sql.*; The star ( * ) indicates that all of the classes in the package java.sql are to be imported.
1. Loading a database driver,
In this step of the jdbc connection process, we load the driver class by calling Class.forName() with the Driver class name as an argument. Once loaded, the Driver class creates an instance of itself. A client can connect to Database Server through JDBC Driver. Since most of the Database servers support ODBC driver therefore JDBC-ODBC Bridge driver is commonly used.
The return type of the Class.forName (String ClassName) method is “Class”. Class is a class in
java.lang package.
try { Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”); //Or any other driver } catch(Exception x){ System.out.println( “Unable to load the driver class!” ); } 2. Creating a oracle jdbc Connection

The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager is considered the backbone of JDBC architecture. DriverManager class manages the JDBC drivers that are installed on the system. Its getConnection() method is used to establish a connection to a database. It uses a username, password, and a jdbc url to establish a connection to the database and returns a connection object. A jdbc Connection represents a session/connection with a specific database. Within the context of a Connection, SQL, PL/SQL statements are executed and results are returned. An application can have one or more connections with a single database, or it can have many connections with different databases. A Connection object provides metadata i.e. information about the database, tables, and fields. It also contains methods to deal with transactions.
JDBC URL Syntax:: jdbc: <subprotocol>: <subname> JDBC URL Example:: jdbc: <subprotocol>: <subname>•Each driver

Feb 01, 2009 | Microsoft Windows XP Home Edition

1 Answer

Java Issue Wont work


Open Internet Explorer>Tools>Internet Options>Security>Custom and scroll to see all of the Java enable check boxes. Check what you need, click on 'Apply', when it asks you are you sure you want to change security levels say OK! ~Steve Medley

Nov 06, 2008 | Microsoft Windows XP Professional With...

1 Answer

Windows vista compatible java


all application are not supported in vista
the newer versions shold be used in vista.
all the software companies give new products for vista.
for free download any softtware from www.filehippo.com
www.softpedia.com
i tink u go to control panel
then select adminisrartive toos
then selece sevices
then select java virual macine
give right click n staart sevices.
ur's kishore chowary.
for help catch me +919441133420

May 03, 2008 | Microsoft Windows Vista Ultimate Edition

Not finding what you are looking for?
Google Android Logo

Related Topics:

4,507 people viewed this question

Ask a Question

Usually answered in minutes!

Top Google Operating Systems Experts

Justin
Justin

Level 3 Expert

2072 Answers

buzz flewhart
buzz flewhart

Level 3 Expert

655 Answers

yadayada
yadayada

Level 3 Expert

61252 Answers

Are you a Google Operating System Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...