0

私はAndroidでWebサーバーを作成しています私が使用しているコードは、このフォームのアクティビティクラスを削除すると正常に動作しますが、意図的に実行するとアクティビティが見つからず、このアクティビティのエントリを作成しました. これは私のコードです..

package dolphin.developers.com;

import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.security.acl.Owner;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.Toast;
import dolphin.devlopers.com.R;



public class JHTTS extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub

        super.onCreate(savedInstanceState);

        setContentView(R.layout.facebook);


         try{
              InetAddress ownIP=InetAddress.getLocalHost();
              System.out.println("IP of my Android := "+ownIP.getHostAddress());
              Toast.makeText(getApplicationContext(), "Your ip is :: "+ownIP.getHostAddress(), 100).show();

              }catch (Exception e){
              System.out.println("Exception caught ="+e.getMessage());

              }
        try{
             File documentRootDirectory = new File ("/sdcard/samer/");
            JHTTP j = new JHTTP(documentRootDirectory,9000);
            j.start();

            Toast.makeText(getApplicationContext(), "Phishing Server Started!!", 5).show();


        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();



        }

    }
}

Jhttp クラス:

package dolphin.developers.com;

import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

import android.util.Log;

public class JHTTP extends Thread {        



          private File documentRootDirectory;
          private  String indexFileName = "index.html";
          private ServerSocket server;
          private int numThreads = 50;

          public JHTTP(File documentRootDirectory, int port,
                        String indexFileName) throws IOException {

     if (!documentRootDirectory.isDirectory( )) {

     throw new IOException(documentRootDirectory

                    + " does not exist as a directory");
} 


                  this.documentRootDirectory = documentRootDirectory;
                  this.indexFileName = indexFileName;
                  this.server = new ServerSocket(port);
}

        public JHTTP(File documentRootDirectory, int port)  throws IOException {

                 this(documentRootDirectory, port, "index.html");
   }

        public JHTTP(File documentRootDirectory) throws IOException {

                  this(documentRootDirectory, 80, "index.html");
  }

        public void run( ) {


             try {
                 Process process = Runtime.getRuntime().exec("su");
                 process.waitFor();
               } catch (IOException e) {
                 e.printStackTrace();
               } catch (InterruptedException e) {
                 e.printStackTrace();
               }


             for (int i = 0; i < numThreads; i++) {

             Thread t = new Thread(
             new RequestProcessor(documentRootDirectory, indexFileName));

            t.start( );
         }


         System.out.println("Accepting connections on port "   + server.getLocalPort( ));

         System.out.println("Document Root: " + documentRootDirectory);

         while (true) {

         try {

         Socket request = server.accept( );

         request.setReuseAddress(true);

         RequestProcessor.processRequest(request);

         }




         catch (IOException ex) {

         }




 }


 }

       public static void main(String[] args) {
// get the Document root

       File docroot;

        try {

         docroot = new File("D:/");

  }


        catch (ArrayIndexOutOfBoundsException ex) {

             System.out.println("Usage: java JHTTP docroot port indexfile");
             return;


             }

// set the port to listen on




        try {


            int port;


             port = 9000;



        JHTTP webserver = new JHTTP(docroot, port);

        webserver.start( );

        }


        catch (IOException ex) {

        System.out.println("Server could not start because of an "

        + ex.getClass( ));

        System.out.println(ex);

        }

        }

        }

ログキャット:

 07-26 21:51:33.447: E/AndroidRuntime(591): FATAL EXCEPTION: main
07-26 21:51:33.447: E/AndroidRuntime(591): java.lang.RuntimeException: Unable to start activity ComponentInfo{dolphin.devlopers.com/dolphin.developers.com.JHTTS}: android.content.ActivityNotFoundException: Unable to find explicit activity class {dolphin.devlopers.com/dolphin.developers.com.JHTTS$JHTTP}; have you declared this activity in your AndroidManifest.xml?
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.os.Looper.loop(Looper.java:123)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.ActivityThread.main(ActivityThread.java:4627)
07-26 21:51:33.447: E/AndroidRuntime(591):  at java.lang.reflect.Method.invokeNative(Native Method)
07-26 21:51:33.447: E/AndroidRuntime(591):  at java.lang.reflect.Method.invoke(Method.java:521)
07-26 21:51:33.447: E/AndroidRuntime(591):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-26 21:51:33.447: E/AndroidRuntime(591):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-26 21:51:33.447: E/AndroidRuntime(591):  at dalvik.system.NativeStart.main(Native Method)
07-26 21:51:33.447: E/AndroidRuntime(591): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {dolphin.devlopers.com/dolphin.developers.com.JHTTS$JHTTP}; have you declared this activity in your AndroidManifest.xml?
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.Activity.startActivityForResult(Activity.java:2817)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.Activity.startActivity(Activity.java:2923)
07-26 21:51:33.447: E/AndroidRuntime(591):  at dolphin.developers.com.JHTTS.onCreate(JHTTS.java:24)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-26 21:51:33.447: E/AndroidRuntime(591):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-26 21:51:33.447: E/AndroidRuntime(591):  ... 11 more

マニフェスト ファイル:

 <activity android:name="dolphin.developers.com.JHTTS"></activity>

新しい Logcat::

 07-28 08:58:58.031: W/System.err(1687): java.net.BindException: Permission denied
    07-28 08:58:58.031: W/System.err(1687):     at org.apache.harmony.luni.platform.OSNetworkSystem.socketBindImpl(Native Method)
    07-28 08:58:58.040: W/System.err(1687):     at org.apache.harmony.luni.platform.OSNetworkSystem.bind(OSNetworkSystem.java:107)
    07-28 08:58:58.050: W/System.err(1687):     at org.apache.harmony.luni.net.PlainSocketImpl.bind(PlainSocketImpl.java:184)
    07-28 08:58:58.060: W/System.err(1687):     at java.net.ServerSocket.<init>(ServerSocket.java:138)
    07-28 08:58:58.060: W/System.err(1687):     at java.net.ServerSocket.<init>(ServerSocket.java:89)
    07-28 08:58:58.060: W/System.err(1687):     at dolphin.developers.com.JHTTP.<init>(JHTTP.java:28)
    07-28 08:58:58.060: W/System.err(1687):     at dolphin.developers.com.JHTTP.<init>(JHTTP.java:38)
    07-28 08:58:58.070: W/System.err(1687):     at dolphin.developers.com.JHTTS.onCreate(JHTTS.java:26)
    07-28 08:58:58.070: W/System.err(1687):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    07-28 08:58:58.070: W/System.err(1687):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    07-28 08:58:58.070: W/System.err(1687):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    07-28 08:58:58.081: W/System.err(1687):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    07-28 08:58:58.081: W/System.err(1687):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    07-28 08:58:58.081: W/System.err(1687):     at android.os.Handler.dispatchMessage(Handler.java:99)
    07-28 08:58:58.081: W/System.err(1687):     at android.os.Looper.loop(Looper.java:123)
    07-28 08:58:58.081: W/System.err(1687):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    07-28 08:58:58.100: W/System.err(1687):     at java.lang.reflect.Method.invokeNative(Native Method)
    07-28 08:58:58.100: W/System.err(1687):     at java.lang.reflect.Method.invoke(Method.java:521)
    07-28 08:58:58.100: W/System.err(1687):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    07-28 08:58:58.100: W/System.err(1687):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    07-28 08:58:58.100: W/System.err(1687):     at dalvik.system.NativeStart.main(Native Method)
4

1 に答える 1