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

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

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

×

Loading...
Loading...

Related Questions:

1 Answer

How do I enable java in win10


Acces the Java Control Panel:
you can find the Java Control Panel through the Windows Start menu.
  1. Launch the Windows Start menu
  2. Click on Programs (All Apps on Windows 10)
  3. Find the Java program folder
  4. Click Configure Java to launch the Java Control Panel
If you don't see the Java folder then assume Java is not installed o your computer, then go to https://www.java.com/fr/download/manual.jsp

  • In the Java Control Panel, click the Security tab.
  • Select the option Enable Java content in the browser.
  • Click Apply and then OK to confirm the changes.
  • Restart the browser to enable the changes.
Hope this help...

Oct 07, 2016 | Computers & Internet

1 Answer

Lg 305 does support internet facilities?


Hi,
The answer is yes!
This phone has an EDGE class 12 internet connection and an installed JAVA, MIDP 2.0 internet browser.
Just launch the Java application to connect to the internet.
See more features.

Hope this helps.Thanks!
Please rate this answer.

Oct 28, 2011 | Cell Phones

1 Answer

Java Vitual Machine Launcher prompts this message "Could not find the main class. Program will exit" How can I solve this problem? I need urgent assistance.


You need to compile the .java file you have, and run the .class file that is produced.
Open up command prompt, go to your working directory. If your file was called Hello.java: In command prompt type "javac Hello.java". Now, in the working directory, you will see a new file, Hello.class. Run that file by "java Hello.class". Hope this helps!
Thanks for using FixYa

Aug 20, 2011 | Sun Java Programming Language (cdj-275)

1 Answer

Why main function is made static in java


Hi,
Its very easy dear. In java everything is object oriented. You will call a function through an object. Now we are calling the main method without any object as we do not create any object of the class that contains a main method. So call the main method we need to declare main as static methos so its not a part of an object but a class so that mian method can be called without having creating any object of the class.
Regards, polysandy

Jun 27, 2010 | Sun Java Programming Language (cdj-275)

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

1 Answer

Jnlp code for the java program


From command prompt: You can also launch an application from a command prompt by typing javaws jnlp_url where jnlp_url is a url to the jnlp file of the application. Go to Start > Run > type "cmd". A command prompt window will appear. Type "javaws url_of_jnlp"

May 28, 2009 | Microsoft Office Word 2007 Upgrade Version...

2 Answers

SECRET CODES


SAMSUNG UNLOCK CODE....
*2767*688# = Unlocking Code
*#8999*8378# = All in one Code
*#4777*8665# = GPSR Tool
*#8999*523# = LCD Brightness
*#8999*3825523# = External Display
*#8999*377# = Errors
#*5737425# = JAVA Something{I choose 2 and it chrashed}][/b]
*#2255# = Call List
#*536961# = Java Status Code
#*536962# = Java Status Code
#*536963# = Java Status Code
#*53696# = Java Status Code

#*1200# = AFC DAC Val
#*1300# = IMEI
#*1400# = IMSI
#*7222# = Operation Typ (Class C GSM)
#*7224# = I Got !! ERROR !!
#*7252# = Oparation Typ (Class B GPRS)
#*7271# = Multi Slot (Class 1 GPRS)
#*7274# = Multi Slot (Class 4 GPRS)
#*7276# = Dunno
#*7337# = EEPROM Reset (Unlock and Resets Wap Settings)
#*2787# = CRTP ON/OFF
#*3737# = L1 Dbg data
#*5133# = L1 Dbg data
#*7288# = GPRS Attached
#*7287# = GPRS Detached
#*7666# = SrCell Data
#*7693# = Sleep Act/DeAct (Enable or Disable the Black screen after doing nothing for a while)
#*7284# = Class : B,C or GPRS
#*2256# = Calibration Info
#*2286# = Battery Data
#*2527# = GPRS Switching (set to: class 4, class 8, class 9 or class 10)
#*2679# = Copycat feature (Activate or Deactivate)
#*3940# = External loop test 9600 bps
#*4263# = Handsfree mode (Activate or Deactivate)
#*4700# = Half Rate (Activate or Deactivate)
#*7352# = BVMC Reg value
#*8462# = Sleeptime
#*2558# = Time ON
#*3370# = EFR (Activate or Deactivate)
#*3941# = External looptest 115200 bps
#*5176# = L1 Sleep
#*7462# = SIM phase
#*7983# = Voltage/Frequenci (Activate or Deactivate)
#*7986# = Voltage (Activate or Deactivate)
#*8466# = Old time
#*2255# = Call ???
#*5187# = L1C2G trace (Activate or Deactivate)
#*5376# = ??? White for 15 secs than restarts.
#*6837# = Official Software Version
#*7524# = KCGPRS
#*7562# = LOCI GPRS
#*7638# = RLC allways open ended TBF (Activate or Deactivate)
#*7632# = Sleep mode Debug
#*7673# = Sleep mode RESET
#*2337# = Permanent Registration Beep

Mar 16, 2009 | Cell Phones

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

2 Answers

Can not open website at home, but it opens everywhere else


hi since ur program launches with java its better to update the java functionality for ur system. latest version of java utilities are available in net.

pls rate me

Jan 21, 2009 | Computers & Internet

1 Answer

Unable to View Java Applet


"load: class JFI.class not found."
Based on the console output, it means that it cannot find the java applet class. In other words, the applet is missing on the server side. There is nothing that you can do about it, unless you know the person who created the applet. Good luck :)

Dec 23, 2008 | ArcMedia JavaScript Source Code 3000 Pro...

Not finding what you are looking for?
Google Android Logo

Related Topics:

4,511 people viewed this question

Ask a Question

Usually answered in minutes!

Top Google Computers & Internet Experts

kakima

Level 3 Expert

102366 Answers

Robet
Robet

Level 2 Expert

29 Answers

Richard Solanski
Richard Solanski

Level 1 Expert

8 Answers

Are you a Google Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...