Hello i have to make an android app , the app is a simple chat of facebook,msn,gmail , only the chat.
the app ask to user to give username and password and login in the chat and he chat with his freind only.
But i cant find samething in the internet to help me.
if sameone can..
thanks allot
41 Replies - 1575 Views - Last Post: 25 December 2012 - 08:11 PM
Replies To: question about chat in android app
#2
Re: question about chat in android app
Posted 18 November 2012 - 02:29 PM
you could start with a look on the api's...
facebook chat:
http://developers.fa....com/docs/chat/
microsoft live
http://msdn.microsof...y/live/hh826539
google
https://developers.google.com/talk/
and hava a look on this
https://developers.g...a/xmpp/overview
facebook chat:
http://developers.fa....com/docs/chat/
microsoft live
http://msdn.microsof...y/live/hh826539
https://developers.google.com/talk/
and hava a look on this
https://developers.g...a/xmpp/overview
#3
Re: question about chat in android app
Posted 19 November 2012 - 01:41 AM
A lot of thanks is so helpfull the links i start to write the app,
And samthing else i want to chose from a spinner witch have all news categori and i want to chose the category from spiner and show the lates news, for exaple choise from spinner the sports how i conect to web page and show the latest news?
And samthing else i want to chose from a spinner witch have all news categori and i want to chose the category from spiner and show the lates news, for exaple choise from spinner the sports how i conect to web page and show the latest news?
#4
Re: question about chat in android app
Posted 19 November 2012 - 05:16 AM
That is a new question and should be posted in a new thread!
this question is rather wide! and this is just a suggestion.
you could create a list of categories. For each categori you could read some rss feeds and display the heading in
a spinner or something. when selecting the heading you could open the coresponding uri in a page.
you could use webview to display webpages.
http://developer.and...it/WebView.html
remember google is your friend! The most difficult thing is to formalize the qustion
this question is rather wide! and this is just a suggestion.
you could create a list of categories. For each categori you could read some rss feeds and display the heading in
a spinner or something. when selecting the heading you could open the coresponding uri in a page.
you could use webview to display webpages.
http://developer.and...it/WebView.html
remember google is your friend! The most difficult thing is to formalize the qustion
#5
Re: question about chat in android app
Posted 19 November 2012 - 07:41 AM
JHol, on 19 November 2012 - 05:16 AM, said:
That is a new question and should be posted in a new thread!
this question is rather wide! and this is just a suggestion.
you could create a list of categories. For each categori you could read some rss feeds and display the heading in
a spinner or something. when selecting the heading you could open the coresponding uri in a page.
you could use webview to display webpages.
http://developer.and...it/WebView.html
remember google is your friend! The most difficult thing is to formalize the qustion
this question is rather wide! and this is just a suggestion.
you could create a list of categories. For each categori you could read some rss feeds and display the heading in
a spinner or something. when selecting the heading you could open the coresponding uri in a page.
you could use webview to display webpages.
http://developer.and...it/WebView.html
remember google is your friend! The most difficult thing is to formalize the qustion
This is the code i make but its not load the webpages
package com.example.multimedia;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;
public class InformationActivity extends Activity {
Button button1;
Spinner spinner1;
WebView webview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.information_layout);
final String[] array1 = { "Sport", "Financial", "Techology", "Auto", "Travel"};
spinner1=(Spinner)findViewById(R.id.spinnermenu);
button1=(Button)findViewById(R.id.gobutton);
webview = (WebView) findViewById(R.id.webView);
// webview.setWebViewClient(new homeClient());
webview.getSettings().setJavascriptEnabled(true);
// ProgressDialog pd = ProgressDialog.show(Home.this, "", "Loading. Please wait...", true);
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, array1);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner1.setAdapter(adapter);
button1.setonclickListener(new View.onclickListener() {
public void onclick(View v) {
String o = (String) spinner1.getSelectedItem ();
if (o == "Sport") {
webview.loadUrl("http://sports.in.gr");
}
else if (o=="Financial"){
webview.loadUrl("http://finance.in.gr");
}
else if (o=="Techology"){
webview.loadUrl("http://tech.in.gr");
}
else if (o=="Auto"){
webview.loadUrl("http://auto.in.gr");
}
else if (o=="Travel"){
webview.loadUrl("http://diakopes.in.gr");
}
} } );
}
}
This post has been edited by H3R3T1C: 19 November 2012 - 02:52 PM
Reason for edit:: fix code tags
#6
Re: question about chat in android app
Posted 19 November 2012 - 11:53 AM
please post your layout.xml file as well
in the code tag, please use... [/code] at the end of code
in the code tag, please use... [/code] at the end of code
#7
Re: question about chat in android app
Posted 19 November 2012 - 12:56 PM
By the way.. Have you set the uses internet permission in androidmanifest
just add this to your androidmanifest in the manifest section:
just add this to your androidmanifest in the manifest section:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
#8
Re: question about chat in android app
Posted 20 November 2012 - 01:09 AM
here is the code
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.multimedia"
android:versionCode="1"
android:versionName="1.0" >
--> where i put the internet permition?
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RadiosActivity" />
<activity android:name=".ChatActivity" />
<activity android:name=".InformationActivity" />
</application>
</manifest>
#9
Re: question about chat in android app
Posted 20 November 2012 - 04:54 AM
yes that should hopefully work:-)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.multimedia"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RadiosActivity" />
<activity android:name=".ChatActivity" />
<activity android:name=".InformationActivity" />
</application>
</manifest>
#10
Re: question about chat in android app
Posted 20 November 2012 - 09:25 AM
i wrote the chat cod but i have problem i have same pazled of code but i cant make it to work i have a lot of errors
menu load code and xml
And the chat class and xml
menu load code and xml
import android.R;
import android.app.Dialog;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
//import error ??
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Presence;
//settings get input and then connection is established
public class xmppsettings extends Dialog implements android.view.View.onclickListener {
private ChatClient chatClient; // error ChatClient
public xmppsettings(ChatClient chatClient){
super(chatClient);
this.chatClient = chatClient; //error
}
protected void onstart() {
super.onstart();
setContentView(R.layout.men); //error
setTitle("Connection Settings");
Button ok = (Button) findViewById(R.id.ok); // eroor
ok.setonclickListener(this);
}
public void onclick(View v) {
String host = getText(R.id.host);//error
String port = getText(R.id.port);//error
String service = getText(R.id.service);//error
String username = getText(R.id.userid);//error
String password = getText(R.id.password);//error
// Create connection
//error
ConnectionConfiguration connectionConfig =
new ConnectionConfiguration(host, Integer.parseInt(port), service);
XMPPConnection connection = new XMPPConnection(connectionConfig);
try {
connection.connect();
} catch (XMPPException ex) { //error
chatClient.setConnection(null);
}
try {
connection.login(username, password);
// Set status to online / available
Presence presence = new Presence(Presence.Type.available); //error
connection.sendPacket(presence);
chatClient.setConnection(connection);
} catch (XMPPException ex) { //error
chatClient.setConnection(null);
}
dismiss();
}
private String getText(int id) {
EditText widget = (EditText) this.findViewById(id);
return widget.getText().toString();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/host"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" />
<TextView
android:id="@+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Host/Port"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/service"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" />
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Service"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/userid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" />
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Userid"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
android:textAppearance="?android:attr/textAppearanceSmall" />
<AutoCompleteTextView
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" >
<requestFocus />
</AutoCompleteTextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK" />
</LinearLayout>
</LinearLayout>
And the chat class and xml
package com.example.multimedia;
import android.app.Activity;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
public class ChatActivity<XMPPConnection> extends Activity {
private ArrayList<String> messages = new ArrayList();
private Handler handler = new Handler();
private xmppsettings settings;// error
private EditText recipient;
private EditText text;
private ListView list;
private XMPPConnection connection;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chat_layout);
recipient = (EditText) this.findViewById(R.id.recipient);
text = (EditText) this.findViewById(R.id.text);
list = (ListView) this.findViewById(R.id.messageList);
setListAdapter();
//Window for getting settings
settings = new xmppsettings(this);// error
//Listener for chat message
Button send = (Button) this.findViewById(R.id.send);
send.setonclickListener(new View.onclickListener() {
public void onclick(View v) {
String to = recipient.getText().toString();
String text1 = text.getText().toString();
Message msg = new Message(to, Message.Type.chat);// error
msg.setBody(text1);// error
connection.sendPacket(msg);
messages.add(connection.getUser() + ":");// error
messages.add(text1);
setListAdapter();
}
});
}
//Called by settings when connection is established
public void setConnection (XMPPConnection connection) {
this.connection = connection;
if (connection != null) {
//Packet listener to get messages sent to logged in user
PacketFilter filter = new MessageTypeFilter(Message.Type.chat); // error
connection.addPacketListener(new PacketListener() { // error
public void processPacket(Packet packet) { // error
Message message = (Message) packet; // error
if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message.getFrom()); // error
messages.add(fromName + ":");
messages.add(message.getBody());
handler.post(new Runnable(){
public void run() {
setListAdapter();
}
});
}
}
}, filter);
}
}
private void setListAdapter() {
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this, R.layout.list, messages); // error
list.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.men, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.settings:
settings.show(); // error
return true;
case R.id.quit: // error
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<!-- Header Starts -->
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@layout/header_gradient"
android:paddingBottom="5dip"
android:paddingTop="5dip" >
<!-- Logo Start -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_weight="0.38"
android:src="@drawable/logo" />
<!-- Logo Ends -->
<Button
android:id="@+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings" />
</LinearLayout>
<!-- Header Ends -->
<!-- Login Form -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/header"
android:orientation="vertical"
android:padding="10dip" >
<!-- Email Label -->
<AutoCompleteTextView
android:id="@+id/recipient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Chat"
android:textColor="#372c24" />
<!-- Password Label -->
<!-- Login button -->
<!-- Link to Registration Screen -->
</LinearLayout>
<!-- Login Form Ends -->
<Button
android:id="@+id/send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Login" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:orientation="vertical" >
</LinearLayout>
<ListView
android:id="@+id/messageList"
android:layout_width="wrap_content"
android:layout_height="208dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/linearLayout1" >
</ListView>
<EditText
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/messageList"
android:ems="10"
android:password="true"
android:singleLine="true" />
</RelativeLayout>
</ScrollView>
#11
Re: question about chat in android app
Posted 20 November 2012 - 03:34 PM
ok, this was a big question
in your xmppsettings.class
creator:
why do you send the chatclient to super?
create instances port,service,userid,and password in their respective types
they should be class variables.
get them from your layout file:something like this
host =(AutoCompleteTextView)getViewById(R.id.host);
in your xmppsettings.class
creator:
why do you send the chatclient to super?
create instances port,service,userid,and password in their respective types
they should be class variables.
get them from your layout file:something like this
host =(AutoCompleteTextView)getViewById(R.id.host);
#12
Re: question about chat in android app
Posted 21 November 2012 - 03:07 AM
a typo in the last post
should be findViewById not getviewbyid
should be findViewById not getviewbyid
#13
Re: question about chat in android app
Posted 21 November 2012 - 08:55 AM
JHol, on 20 November 2012 - 03:34 PM, said:
ok, this was a big question
in your xmppsettings.class
creator:
why do you send the chatclient to super?
create instances port,service,userid,and password in their respective types
they should be class variables.
get them from your layout file:something like this
host =(AutoCompleteTextView)getViewById(R.id.host);
in your xmppsettings.class
creator:
why do you send the chatclient to super?
create instances port,service,userid,and password in their respective types
they should be class variables.
get them from your layout file:something like this
host =(AutoCompleteTextView)getViewById(R.id.host);
can't you give me an exaple how i make instances port?
#14
Re: question about chat in android app
Posted 21 November 2012 - 04:27 PM
I think you have to start on the top xmppsettings and fix your imports before dooing anything with the rest of the code.
Have you installed the smack package(smack.jar) which contains the imports in your code. or is this just copy paste?
Have you installed the smack package(smack.jar) which contains the imports in your code. or is this just copy paste?
#15
Re: question about chat in android app
Posted 23 November 2012 - 11:02 AM
Yes its piece of code from net and i try to make it to work but i cant...
|
|

New Topic/Question
Reply


MultiQuote




|