Android Zugriff auf FTP-Server

Kratos

Mitglied
Ich entwickle zurzeit eine App, die unter Anderem auf meinen FTP-Server zugreifen soll.
Dazu verwende ich einen Sourcecode von einem früheren Projekt, allerdings ein Java Programm
und keine Android Application:

Der Sourcecode, hier wird einfach nur eine FTP datei ausgelesen, ein String draufgeklatscht und sie wieder hochgeladen:
Java:
try{
			
			URL url = new URL("ftp://*****;type=i");
			URLConnection urlc = url.openConnection();
			urlc = url.openConnection();
			
			InputStream is = urlc.getInputStream();
			InputStreamReader readerS = new InputStreamReader(is);
			BufferedReader r = new BufferedReader(readerS);
			
			String msg = null; 
			
			while((msg = r.readLine()) != null){
				actualText += msg + "\n";
			}
			
			readerS.close();
			r.close();
			is.close();
			urlc = null;
			
			url = new URL("ftp://u78111953:Ichbingut1!@senad-alic.com/python/abx.txt;type=i");
			urlc = url.openConnection();
			
			BufferedWriter wr=new BufferedWriter(new OutputStreamWriter(urlc.getOutputStream()));
			
			
			wr.write(uploadText + "\n\n\n" + actualText);
			wr.flush();
			wr.close();
			urlc = null;
			
			
			}catch(IOException e ){
			}

Mein App-Source Code, die "sendEditor" Methode geht los beim Drücken des Buttons auf meiner APP
Java:
//hier sind alle Importe

public class MainActivity extends ActionBarActivity {

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
	public void sendEditor(View view) {
	    
	    EditText textf = (EditText) findViewById(R.id.editText);
	    Log.v("Ausgabe", ""+textf.getText());
	    try{
			String actualText = "";
			URL url = new URL("ftp://**********");
			URLConnection urlc = url.openConnection();
			urlc = url.openConnection();
			
			InputStream is = urlc.getInputStream();
			InputStreamReader readerS = new InputStreamReader(is);
			BufferedReader r = new BufferedReader(readerS);
			
			String msg = null; 
			
			while((msg = r.readLine()) != null){
				actualText += msg + "\n";
			}

			readerS.close();
			r.close();
			is.close();
			urlc = null;
			
			url = new URL("ftp://");
			urlc = url.openConnection();
			
			BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(urlc.getOutputStream()));
			
			DateFormat df=DateFormat.getDateInstance(DateFormat.MEDIUM);
			
			df=DateFormat.getTimeInstance(DateFormat.SHORT);
			
			String uploadText= ""+textf.getText();
			wr.write(uploadText + "\n\n\n" + actualText);
			wr.flush();
			wr.close();
			urlc = null;
			
			
			}catch(IOException e ){
				Log.v("Ausgabe", "Schon wieder eine dumme Exception!");
			}
		
			
	}
}
Hier die XML meines Layouts
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="de.python.duracal.MainActivity" >

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message"
        android:inputType="textMultiLine" >

    </EditText>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="sendEditor"
        android:text="Editor" />

</LinearLayout>
Und hier sollte eigentlich alles in Ordnung sein, Rechte auf Internet gewährleistet
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.python.duracal"
    android:versionCode="1"
    android:versionName="1.0" >
	<uses-permission android:name="android.permission.INTERNET" /> 
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="20" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Die App bleibt bei
Java:
InputStream is = urlc.getInputStream();
hängen

Hat jemand Ansätze? :)

Ich finde es einfach nur seltsam, dass es bei einer normalen Java-App klappt aber nicht bei einer
für Android, trotz gleichen Sourcecodes....
 
Zuletzt bearbeitet:
Ähnliche Java Themen
  Titel Forum Antworten Datum
L Zugriff auf entfernten mySQL-Server via Android Android & Cross-Platform Mobile Apps 4
S Android Zugriff auf FTP Server Android & Cross-Platform Mobile Apps 7
W onViewCreated blockiert Session Zugriff gegensatz zu onCreateView? Fragment Android & Cross-Platform Mobile Apps 25
R Android Zugriff auf view von MainActivity Android & Cross-Platform Mobile Apps 7
J Android Zugriff auf eine Datei, diese von einer anderen App erstellt wurde? Android & Cross-Platform Mobile Apps 11
M Zugriff auf Helligkeitsregler von Handy? Android & Cross-Platform Mobile Apps 17
C Zugriff auf die Position eines String- bzw Spinner-Arrays Android & Cross-Platform Mobile Apps 1
E Wie erhalte ich Zugriff auf das Microfon? (Android Studio) Android & Cross-Platform Mobile Apps 9
B Android Kein Zugriff auf Telefonspeicher (Android 6) Android & Cross-Platform Mobile Apps 1
N Zugriff auf TextView in ListItem via ButtonClick Android & Cross-Platform Mobile Apps 4
S Android Zugriff auf Bilder im Telefonspeicher + Galeriedarstellung Android & Cross-Platform Mobile Apps 5
N Android Zugriff auf PlayStore im Abgesicherten Modus verhindern Android & Cross-Platform Mobile Apps 2
T Android Reflection zugriff auf setFocusableInTouchMode Android & Cross-Platform Mobile Apps 5
L Android Zugriff aus unbound Service auf Preferences Android & Cross-Platform Mobile Apps 2
H Smartphone (Front-)Kamera-Zugriff per Website Android & Cross-Platform Mobile Apps 6
S Android Zugriff auf Website fuers Infos Android & Cross-Platform Mobile Apps 2
C Java ME Kein Java Zugriff auf Samsung! Android & Cross-Platform Mobile Apps 5
R Java ME mit Zugriff auf Adressbuch / Kalender Android & Cross-Platform Mobile Apps 3
H FileConnection: Frage nach Dateisystem-Zugriff unterdrücken Android & Cross-Platform Mobile Apps 5
1 zugriff auf handy-microfon Android & Cross-Platform Mobile Apps 2
H Zugriff auf XML/DB oder aehnliches Android & Cross-Platform Mobile Apps 3
G Zugriff auf den gesamten Bildschirm bei PDAs Android & Cross-Platform Mobile Apps 8
M Einfache Rechenoperation über TCP Server Android & Cross-Platform Mobile Apps 15
J Android Server-Login Daten in der App sicherer hinterlegen? Android & Cross-Platform Mobile Apps 7
M App Datenbank Server Android & Cross-Platform Mobile Apps 5
B Android TCP-Verbindung zum Server über welche Prozess auslagerung nutzen? Android & Cross-Platform Mobile Apps 1
N Android Client-Server-Kommunikation: push oder poll? Android & Cross-Platform Mobile Apps 10
M Android Nur erste Zeile wird vom Server empfangen Android & Cross-Platform Mobile Apps 0
M Android Server-Client-Verbindung in Android-App mit Sockets aufbauen Android & Cross-Platform Mobile Apps 5
K Android verbinden mit verschlüsselten Server Android & Cross-Platform Mobile Apps 2
M Inhalt eines Eingabefeldes an einen Server senden? Android & Cross-Platform Mobile Apps 9
T Android KontrollApp für Nitrado Server Android & Cross-Platform Mobile Apps 2
D gpx-Datei von Smartphone auf Server uploaden Android & Cross-Platform Mobile Apps 4
S Android binäre Daten zwischen Android und einem Java-Server Android & Cross-Platform Mobile Apps 5
K BT-Server EOFException abfangen Android & Cross-Platform Mobile Apps 2
M Android Von Smartphone auf Daten von Server zugreifen Android & Cross-Platform Mobile Apps 2
N Java ME Server-Client Verbindung über Wifi Android & Cross-Platform Mobile Apps 6
F Server - Client Verbindung mit Java ME Android & Cross-Platform Mobile Apps 3
A "HandyClient-Server-modell" Android & Cross-Platform Mobile Apps 7
D messages via xml zwischen server/clienthandy verschicken Android & Cross-Platform Mobile Apps 5

Ähnliche Java Themen

Neue Themen


Oben