Tech
Batal
KATEGORI
link has been copied
Pengumuman! Ikuti Surveynya, Dapatkan Badge-nya! Klik Disini
9997
KASKUS
51
244
https://www.kaskus.co.id/thread/000000000000000005259433/android-developer-room
hi gan ane lgi coba2 maen android nih... disini ada juga g sih yg maen2 android juga ?? share ilmu2nya donk disini :D apa itu android ?? Android is an operating system for mobile devices such as mobile phones, tablet computers and netbooks. Android is developed by Google and is based upon the Linux kernel and GNU software. It was initially developed by Android Inc. (a firm purchased by Google) and
Lapor Hansip
11-09-2010 18:44

Android Developer Room

Android Developer Room

hi gan
ane lgi coba2 maen android nih...
disini ada juga g sih yg maen2 android juga ??
share ilmu2nya donk disini emoticon-Big Grin

apa itu android ??
Quote:Original Posted By what is android ??

Android is an operating system for mobile devices such as mobile phones, tablet computers and netbooks. Android is developed by Google and is based upon the Linux kernel and GNU software. It was initially developed by Android Inc. (a firm purchased by Google) and later positioned in the Open Handset Alliance.[4] According to NPD Group, unit sales for Android OS smartphones ranked first among all smartphone OS handsets sold in the U.S. in the second quarter of 2010, at 33%.[5][6] BlackBerry OS is second at 28%, and iOS is ranked third with 22%.[7]

Android has a large community of developers writing application programs ("apps") that extend the functionality of the devices. There are currently over 70,000 apps available for Android with some estimates saying 100,000 have been submitted,[8] which makes it the second most popular mobile development environment.[9] Developers write managed code in the Java language, controlling the device via Google-developed Java libraries.[10] A Ruby implementation, allowing full Android apps to be written in Ruby, is in development.[11]

The unveiling of the Android distribution on 5 November 2007 was announced with the founding of the Open Handset Alliance, a consortium of 78 hardware, software, and telecom companies devoted to advancing open standards for mobile devices.[12][13] Google released most of the Android code under the Apache License, a free software and open source license.[14]

The Android operating system software stack consists of Java applications running on a Java based object oriented application framework on top of Java core libraries running on a Dalvik virtual machine featuring JIT compilation. Libraries written in C include the surface manager, OpenCore[15] media framework, SQLite relational database management system, OpenGL ES 2.0 3D graphics API, WebKit layout engine, SGL graphics engine, SSL, and Bionic libc. The Android operating system consists of 12 million lines of code including 3 million lines of XML, 2.8 million lines of C, 2.1 million lines of Java, and 1.75 million lines of C++.[16]


yaq android yg dimaksud ada lah salah satu OS mobile yg lgi beken saat ini...
dan karena device mobile nya lgi beken saat ini.. maka development apps nya pun menjadi salah satu peluang yg menjanjikan dimasa depan emoticon-Big Grin

bagi yg mau ikutan juga ttg android bisa donlod SDK nya disini
Quote:Original Posted By sdk

http://developer.android.com/sdk/index.html


ato klo mau cepet bisa buka xml nya trus donlod linknya dewe emoticon-Big Grin
Quote:
https://dl-ssl.google.com/android/re...repository.xml


Android itu based code nya java gan.. jd mungkin pemain J2me sudah agak familiar nih (ane g pernah maen j2me emoticon-Hammer pernah nya bikin apps WM)
cm utk tampilannya dy pake xml (ane juga bingung nih --a apa j2me gini juga yah --a)

utk tutorial dan documentasi nya bisa cek disini
Quote:
http://developer.android.com/guide/b...s-android.html


sekian dulu gan.. ane mau liat dulu peminat nya emoticon-Big Grin
klo ada peminat nya nanti ane mau coba share2 ilmu disini emoticon-Big Grin
jgn blg ane sakti gan.. ane juga baru coba2 emoticon-Hammer
bwat agan2 yg lbh sakti dr ane bantu share juga yah gan emoticon-Big Grin

Update 14 Sept

update 16 Sept List Tutor and buku dr kaskuser

update 23 sept
0
Tampilkan isi Thread
icon-close-thread
Thread sudah digembok
Halaman 59 dari 501
Android Developer Room
16-07-2011 23:48
Quote:Original Posted By rizkyYVCP
gan bisa lebih detail ga...??
mklum nih newbie...
emoticon-Frown


Lebih detail gmn gan, pertanyaan sampean jg kaga detil emoticon-Hammer

Kalo yg gw nangkep, sampean pengen akses server, dan nampilin isi server nya (menu2 makanan plus promo) di applikasi android.

Sampean kesulitannya di mana? emoticon-Confused:


Just a friendly advice. Kalo bikin skripsi jgn yg beribet gan. emoticon-Big Grin
Mendingan bikin apa yg udah dimengerti drpd belajar semua yg baru.
Belajar nanti aja di dunia kerja. Kan enak belajar sambil digaji pula emoticon-Malu
0 0
0
Android Developer Room
17-07-2011 02:34
Quote:Original Posted By kakus-ers
Bisa di database, ato di file.
Tp biasa sih disimpan di Preference


Kalau Preference itu bentuknya apa yah gan ? File XML atau gimana tuh ?
Ada contohnya nda gan ? emoticon-Malu
Mohon petunjuk gan
0 0
0
Android Developer Room
17-07-2011 14:15
Quote:Original Posted By PenghuniKaskus
Kalau Preference itu bentuknya apa yah gan ? File XML atau gimana tuh ?
Ada contohnya nda gan ? emoticon-Malu
Mohon petunjuk gan


Preference itu ya preference. Gmn cara android nyimpennya? gak tau emoticon-Embarrassment
Yg jelas value yg gw simpen, bisa dipanggil lagi, itu kan yg penting emoticon-Big Grin
Value nya persistence, jd sekali disimpen dia ada terus di applikasi walopun aplikasi nya dah restart.

Salah satu cara pake:

Simpen preference:
Code:

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
preferences.edit().putString("simpenan", "Aura Kasih").commit();


Ambil preference
Code:

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String simpenan = preferences.getString("simpenan", "gak punya simpenan emoticon-Frown");



Coba jg baca soal PreferenceActivity
0 0
0
Android Developer Room
17-07-2011 14:19
om nanya dong...
kalo ambil data database..trus ditampilin bentuk listview

caranya gimana ya?
di tampung dulu di array apa gimana?

newbie nih...
0 0
0
Android Developer Room
17-07-2011 15:11
Quote:Original Posted By rizkyYVCP
gan bisa lebih detail ga...??
mklum nih newbie...
emoticon-Frown


mending ambil materi lain deh,soalnya gw liat sampean blm ngerti gimana cara komunikasi aplikasi yang mo dibikin ke server,contoh: untuk apa ada server di tengah2 antara server restoran ama aplikasi?sedangkan server restoran sendiri adalah front-end dari database,mo ada berapa layer emang dari aplikasi di device tuk bisa akses data di database
0 0
0
Android Developer Room
17-07-2011 17:31
Quote:Original Posted By dharmawidhi
om nanya dong...
kalo ambil data database..trus ditampilin bentuk listview

caranya gimana ya?
di tampung dulu di array apa gimana?

newbie nih...


Pke SimpleCursorAdapter aja gan.
Dijamin mantab dan puas
0 0
0
Android Developer Room
17-07-2011 18:42
gan, klo misal kondisi nya kaya kmrn, cuma ane mau insert skrg, gmn ya?

mohon bantuannya lagi gan, mentok lg emoticon-Berduka (S)
0 0
0
Android Developer Room
17-07-2011 21:18
gan tanya ane kan download title dari RSS nya kompas.com

nah semua title yang di download sama aplikasi ane ini, ditampung dalam variabel array string bernama strTitle

variabel strTitle nya ane deklarasiin sebagai variabel global kok gan, jadi harusnya bisa dibaca di luar function

function DownloadRSS buat download title yang ada di RSSfeed
Code:

InputStream in = null;
try {
in = connect.OpenHttpConnection(URL);
Document doc = null;
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db;

try {
db = dbf.newDocumentBuilder();
doc = db.parse(in);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

doc.getDocumentElement().normalize();

//---retrieve all the <item> nodes---
NodeList itemNodes = doc.getElementsByTagName("item");
//--Download All Items
for (int i = 0; i < itemNodes.getLength() ; i++) {
Node itemNode = itemNodes.item(i);
if (itemNode.getNodeType() == Node.ELEMENT_NODE)
{
//---convert the Node into an Element---
Element itemElement = (Element) itemNode;

//---get all the <title> element under the <item>
// element---
NodeList titleNodes =
(itemElement).getElementsByTagName("title");
NodeList dateNodes =
\t(itemElement).getElementsByTagName("pubDate");
//---convert a Node into an Element---
Element titleElement = (Element) titleNodes.item(0);
Element dateElement = (Element) dateNodes.item(0);
//---get all the child nodes under the <title> element---
NodeList textNodes =
((Node) titleElement).getChildNodes();
NodeList textdate =
\t((Node) dateElement).getChildNodes();

//---retrieve the text of the <title> element---
strTitle[i] = ((Node) textNodes.item(0)).getNodeValue();
strDate[i] = ((Node) textdate.item(0)).getNodeValue();


}
}

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


ane mau masukin isi dari variabel strTitle ke dalam ListView

code nya seperti ini
java code buat nampilik ke listview
Code:

DownloadRSS("http://www.kompas.com/getrss/all");
\tListView lv1=(ListView)findViewById(R.id.listViewkompas);
\tlv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , strTitle));


xml
Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidemoticon-Embarrassmentrientation="vertical"
android:background="@drawable/backgroundkompas">

<ListView android:layout_width="match_parent"
android:layout_height="300dip"
android:id="@+id/listViewkompas"
android:layout_alignParentLeft="true"
android:layout_marginTop="45dip"></ListView>
</RelativeLayout>


nah pertama kan panggil function downloadRSS, udah work gan kalau ane pakein textview, terus ane googling cara make ListView dan nemu kayak gitu gan, di eclipse sih gak error tapi pas dijalanin error

dan ane debug alasannya "Null Exception Pointer"

kira2 masalahnya dimana ya gan
0 0
0
Android Developer Room
17-07-2011 22:34
Quote:Original Posted By goons
gan tanya ane kan download title dari RSS nya kompas.com

nah semua title yang di download sama aplikasi ane ini, ditampung dalam variabel array string bernama strTitle

variabel strTitle nya ane deklarasiin sebagai variabel global kok gan, jadi harusnya bisa dibaca di luar function

function DownloadRSS buat download title yang ada di RSSfeed
Code:

InputStream in = null;
try {
in = connect.OpenHttpConnection(URL);
Document doc = null;
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db;

try {
db = dbf.newDocumentBuilder();
doc = db.parse(in);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

doc.getDocumentElement().normalize();

//---retrieve all the <item> nodes---
NodeList itemNodes = doc.getElementsByTagName("item");
//--Download All Items
for (int i = 0; i < itemNodes.getLength() ; i++) {
Node itemNode = itemNodes.item(i);
if (itemNode.getNodeType() == Node.ELEMENT_NODE)
{
//---convert the Node into an Element---
Element itemElement = (Element) itemNode;

//---get all the <title> element under the <item>
// element---
NodeList titleNodes =
(itemElement).getElementsByTagName("title");
NodeList dateNodes =
\t(itemElement).getElementsByTagName("pubDate");
//---convert a Node into an Element---
Element titleElement = (Element) titleNodes.item(0);
Element dateElement = (Element) dateNodes.item(0);
//---get all the child nodes under the <title> element---
NodeList textNodes =
((Node) titleElement).getChildNodes();
NodeList textdate =
\t((Node) dateElement).getChildNodes();

//---retrieve the text of the <title> element---
strTitle[i] = ((Node) textNodes.item(0)).getNodeValue();
strDate[i] = ((Node) textdate.item(0)).getNodeValue();


}
}

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


ane mau masukin isi dari variabel strTitle ke dalam ListView

code nya seperti ini
java code buat nampilik ke listview
Code:

DownloadRSS("http://www.kompas.com/getrss/all");
\tListView lv1=(ListView)findViewById(R.id.listViewkompas);
\tlv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , strTitle));


xml
Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidemoticon-Embarrassmentrientation="vertical"
android:background="@drawable/backgroundkompas">

<ListView android:layout_width="match_parent"
android:layout_height="300dip"
android:id="@+id/listViewkompas"
android:layout_alignParentLeft="true"
android:layout_marginTop="45dip"></ListView>
</RelativeLayout>


nah pertama kan panggil function downloadRSS, udah work gan kalau ane pakein textview, terus ane googling cara make ListView dan nemu kayak gitu gan, di eclipse sih gak error tapi pas dijalanin error

dan ane debug alasannya "Null Exception Pointer"

kira2 masalahnya dimana ya gan



Gak bisa keliatan terlalu banyak kalo kodenya cuma segini.
Kalo downloadRSS nya sudah pasti gak ada error, kemungkinan variable strTitle nya null.
0 0
0
Android Developer Room
18-07-2011 01:06
Quote:Original Posted By Raixen
gan, klo misal kondisi nya kaya kmrn, cuma ane mau insert skrg, gmn ya?

mohon bantuannya lagi gan, mentok lg emoticon-Berduka (S)


Ya tinggal ganti sql nya jd insert emoticon-Confused:
mentoknya di mana?
0 0
0
Android Developer Room
18-07-2011 07:54
Quote:Original Posted By agaz
iya bro, minimal requirement 2.2 froyo soalnya emoticon-Frown


gan minta kirimin source code nya dong.. pm me klo agan bisa bantu buat skripsiong.. emoticon-Add Friend (S)
0 0
0
Android Developer Room
18-07-2011 12:01
Quote:Original Posted By kakus-ers
Ya tinggal ganti sql nya jd insert emoticon-Confused:
mentoknya di mana?


kayaknya ada salah di insert nya ni gan, cuma bingung salahnya dimana emoticon-Bingung (S)

insert.java
Code:

package com.example.mysql;

import lib.fenli.mysql.MySQLConnection;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class insert extends Activity implements android.view.View.OnClickListener{
\tprivate Button insert;
\tprivate EditText user, pass;
\t@Override
\t public void onCreate(Bundle savedInstanceState) {
\t super.onCreate(savedInstanceState);
\t setContentView(R.layout.insert);
\t
\t insert = (Button) findViewById(R.id.input);
\t user = (EditText) findViewById(R.id.username);
\t pass = (EditText) findViewById(R.id.password);
\t

\t
\t }


\t@Override
\tpublic void onClick(View v) {
\t\t
\t\tMySQLConnection conn = new MySQLConnection();
// melakukan query
\t\tif (v == insert){
\t\t\t
\t\t
conn.query("INSERT INTO login(username, password) values(user, pass)");
Toast.makeText(insert.this, "upload sukses", Toast.LENGTH_SHORT).show();
\t\t}

// menutup koneksi
conn.close();
\t\t
\t}
}



insert.xml
Code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
androidemoticon-Embarrassmentrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_marginTop="20px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Input Data User pada MySQL"
android:gravity="center"
android:textSize="20px"
></TextView>
<EditText
android:layout_marginTop="20px"
android:id="@+id/username"
android:layout_width="150px"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Username"
android:layout_gravity="center"
></EditText>
<EditText
android:id="@+id/password"
android:layout_width="150px"
android:layout_height="wrap_content"
android:hint="Password"
androidemoticon-Stick Out Tongueassword="true"
android:gravity="center"
android:layout_gravity="center"
></EditText>
<Button
android:id="@+id/input"
android:layout_width="150px"
android:layout_height="wrap_content"
android:text="Input"
android:layout_gravity="center"
></Button>

</LinearLayout>



table login
id username password
1 A A
2 B B

mohon bantuannya lagi gan, sorry merepotkan lagi emoticon-Berduka (S)
0 0
0
Android Developer Room
18-07-2011 12:23
mastah bantuin ane
ane kan punya database namanya biologi
terus tabelnya kamus
dan fieldnya istilah sama arti
nah yang ane bingung gimana ya cara buat delete rownya???
ane udah ngotak ngatik listing buat insert row biar jadi delete row malah ke delete semua rownya
ini listing insertnya
Code:
public void onClick(View clicked) {
\t\tSQLiteDatabase db = updateHelper.getWritableDatabase();
\t\tswitch (clicked.getId()) {
\t\t\tcase R.id.updateOK:
\t\t\t\tContentValues insertdb = new ContentValues(1);
\t\t\t\tinsertdb.put("istilah", getIstilah());
\t\t\t\tinsertdb.put("arti", getArti());
\t\t\t\tdb.insert("biologi", null, insertdb);

nah kalo listing deletenya db.insertnya ane ganti jadi db.delete("biologi", "istilah",null);
eh pas dijalanin malah ilang semua data ane
apa yang salah ya gan???
0 0
0
Android Developer Room
18-07-2011 17:13
Quote:Original Posted By kakus-ers
Gak bisa keliatan terlalu banyak kalo kodenya cuma segini.
Kalo downloadRSS nya sudah pasti gak ada error, kemungkinan variable strTitle nya null.


Ternyata masalahnya gini gan, bukan masalah text / listview nya

yang salah itu ternyata dari alamat nya gan ada yang bisa ada yang nggak

ane coba RSS dari beberapa webstite berita :

[url]http://rss.detik..com/[/url] >> worked gan
http://rss.vivanews.com/get/all >> ini juga worked gan
http://www.kompas.com/getrss/all/ >> not worked
http://www.seputarindonesia.com/rss/category/0 >> not worked

ketika ane debug, ternyata alamat yang gak bisa ketika program melakukan download , itu kayak gak ada yang ter-download gan , koneksi sih bisa tapi gak ada yang terambil alias kita mendownload halaman page kosong.

alhasil ketika kosong variabel nya pada null, makannya error.

nih gan SC yang lengkap

connect.java , ini class yang berfungsi melakukan httpconnection ke url RSS yang dituju (ane pikir kayanya disini yang perlu diubah)
Code:

public class connect {
public static InputStream OpenHttpConnection(String urlString)
throws IOException
{
InputStream in = null;
int response = -1;

URL url = new URL(urlString);
URLConnection conn = url.openConnection();

if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");

try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);

httpConn.setRequestMethod("GET");
httpConn.connect();

response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream();
}
}
catch (Exception ex)
{
throw new IOException("Error connecting");
}
return in;
}
}


kompascom.java
nah ini yang bakal mengambil item RSS untuk title nya , dengan memanggil method connect

Code:

public class Kompascom extends Activity implements OnClickListener{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newskompas);

View tombolKembali = findViewById(R.id.backbutton);
tombolKembali.setOnClickListener(this);
View tombolSambung = findViewById(R.id.connectbutton);
tombolSambung.setOnClickListener(this);

}
String strTitle[] = new String[12];
String strDate[]= new String[12];
private ListView lv1;

public void onClick(View v)
{
\t
\t\tswitch(v.getId())
\t{
\t\tcase R.id.backbutton:\t
\t\t\tfinish();
\t\tbreak;
\t\tcase R.id.connectbutton:\t
\t\t\tDownloadRSS("http://www.kompas.com/getrss/all/");
\t\t\tlv1=(ListView)findViewById(R.id.listViewKompas);

\t\tlv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , strTitle ));
break;
}
}


public void DownloadRSS(String URL)
{
\t
InputStream in = null;
try {
in = connect.OpenHttpConnection(URL);
Document doc = null;
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db;

try {
db = dbf.newDocumentBuilder();
doc = db.parse(in);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

doc.getDocumentElement().normalize();

//---retrieve all the <item> nodes---
NodeList itemNodes = doc.getElementsByTagName("item");
//--Download All Items
for (int i = 0; i <= 11; i++) {
Node itemNode = itemNodes.item(i);
if (itemNode.getNodeType() == Node.ELEMENT_NODE)
{
//---convert the Node into an Element---
Element itemElement = (Element) itemNode;

//---get all the <title> element under the <item>
// element---
NodeList titleNodes =
(itemElement).getElementsByTagName("title");
NodeList dateNodes =
\t(itemElement).getElementsByTagName("pubDate");
//---convert a Node into an Element---
Element titleElement = (Element) titleNodes.item(0);
Element dateElement = (Element) dateNodes.item(0);
//---get all the child nodes under the <title> element---
NodeList textNodes =
((Node) titleElement).getChildNodes();
NodeList textdate =
\t((Node) dateElement).getChildNodes();

//---retrieve the text of the <title> element---
strTitle[i] = ((Node) textNodes.item(0)).getNodeValue();
strDate[i] = ((Node) textdate.item(0)).getNodeValue();


}
}

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



kira2 ya dimana masalah nya gan, udah cukup stuck ane sampe sini emoticon-Frown
0 0
0
Android Developer Room
18-07-2011 17:25
Quote:Original Posted By goons
Ternyata masalahnya gini gan, bukan masalah text / listview nya

yang salah itu ternyata dari alamat nya gan ada yang bisa ada yang nggak

ane coba RSS dari beberapa webstite berita :

[url]http://rss.detik..com/[/url] >> worked gan
http://rss.vivanews.com/get/all >> ini juga worked gan
http://www.kompas.com/getrss/all/ >> not worked
http://www.seputarindonesia.com/rss/category/0 >> not worked

ketika ane debug, ternyata alamat yang gak bisa ketika program melakukan download , itu kayak gak ada yang ter-download gan , koneksi sih bisa tapi gak ada yang terambil alias kita mendownload halaman page kosong.

alhasil ketika kosong variabel nya pada null, makannya error.

nih gan SC yang lengkap

connect.java , ini class yang berfungsi melakukan httpconnection ke url RSS yang dituju (ane pikir kayanya disini yang perlu diubah)
Code:

public class connect {
public static InputStream OpenHttpConnection(String urlString)
throws IOException
{
InputStream in = null;
int response = -1;

URL url = new URL(urlString);
URLConnection conn = url.openConnection();

if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");

try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);

httpConn.setRequestMethod("GET");
httpConn.connect();

response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream();
}
}
catch (Exception ex)
{
throw new IOException("Error connecting");
}
return in;
}
}


kompascom.java
nah ini yang bakal mengambil item RSS untuk title nya , dengan memanggil method connect

Code:

public class Kompascom extends Activity implements OnClickListener{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newskompas);

View tombolKembali = findViewById(R.id.backbutton);
tombolKembali.setOnClickListener(this);
View tombolSambung = findViewById(R.id.connectbutton);
tombolSambung.setOnClickListener(this);

}
String strTitle[] = new String[12];
String strDate[]= new String[12];
private ListView lv1;

public void onClick(View v)
{
\t
\t\tswitch(v.getId())
\t{
\t\tcase R.id.backbutton:\t
\t\t\tfinish();
\t\tbreak;
\t\tcase R.id.connectbutton:\t
\t\t\tDownloadRSS("http://www.kompas.com/getrss/all/");
\t\t\tlv1=(ListView)findViewById(R.id.listViewKompas);

\t\tlv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , strTitle ));
break;
}
}


public void DownloadRSS(String URL)
{
\t
InputStream in = null;
try {
in = connect.OpenHttpConnection(URL);
Document doc = null;
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db;

try {
db = dbf.newDocumentBuilder();
doc = db.parse(in);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

doc.getDocumentElement().normalize();

//---retrieve all the <item> nodes---
NodeList itemNodes = doc.getElementsByTagName("item");
//--Download All Items
for (int i = 0; i <= 11; i++) {
Node itemNode = itemNodes.item(i);
if (itemNode.getNodeType() == Node.ELEMENT_NODE)
{
//---convert the Node into an Element---
Element itemElement = (Element) itemNode;

//---get all the <title> element under the <item>
// element---
NodeList titleNodes =
(itemElement).getElementsByTagName("title");
NodeList dateNodes =
\t(itemElement).getElementsByTagName("pubDate");
//---convert a Node into an Element---
Element titleElement = (Element) titleNodes.item(0);
Element dateElement = (Element) dateNodes.item(0);
//---get all the child nodes under the <title> element---
NodeList textNodes =
((Node) titleElement).getChildNodes();
NodeList textdate =
\t((Node) dateElement).getChildNodes();

//---retrieve the text of the <title> element---
strTitle[i] = ((Node) textNodes.item(0)).getNodeValue();
strDate[i] = ((Node) textdate.item(0)).getNodeValue();


}
}

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



kira2 ya dimana masalah nya gan, udah cukup stuck ane sampe sini emoticon-Frown


kaya gimana sihj gan?
0 0
0
Android Developer Room
18-07-2011 18:02
jadi download title dari halaman rss gan

kalau bisa kayak gini

rss


nah kalau alamat yang gak bisa pas ane click tombol sambung, app nya keluar sendiri, ya masalahnya itu yang ane tulis sebelumnya
0 0
0
Android Developer Room
18-07-2011 23:24
Misi suhu.

Ada yang ngerti gmn cara ngonvert image ke base64 g?
Biar bisa dimasukin ke dalam db. kebetulan ane make mysql sama php buat servernya.

Mungkin ada yg pernah bikin ? nuhun gan
0 0
0
Android Developer Room
19-07-2011 02:12
Quote:Original Posted By goons
Ternyata masalahnya gini gan, bukan masalah text / listview nya

yang salah itu ternyata dari alamat nya gan ada yang bisa ada yang nggak

ane coba RSS dari beberapa webstite berita :

[url]http://rss.detik..com/[/url] >> worked gan
http://rss.vivanews.com/get/all >> ini juga worked gan
http://www.kompas.com/getrss/all/ >> not worked
http://www.seputarindonesia.com/rss/category/0 >> not worked

ketika ane debug, ternyata alamat yang gak bisa ketika program melakukan download , itu kayak gak ada yang ter-download gan , koneksi sih bisa tapi gak ada yang terambil alias kita mendownload halaman page kosong.

alhasil ketika kosong variabel nya pada null, makannya error.

nih gan SC yang lengkap

connect.java , ini class yang berfungsi melakukan httpconnection ke url RSS yang dituju (ane pikir kayanya disini yang perlu diubah)
Code:

public class connect {
public static InputStream OpenHttpConnection(String urlString)
throws IOException
{
InputStream in = null;
int response = -1;

URL url = new URL(urlString);
URLConnection conn = url.openConnection();

if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");

try{
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);

httpConn.setRequestMethod("GET");
httpConn.connect();

response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream();
}
}
catch (Exception ex)
{
throw new IOException("Error connecting");
}
return in;
}
}


kira2 ya dimana masalah nya gan, udah cukup stuck ane sampe sini emoticon-Frown


Kayak gini doang, gak bisa gan?

Code:

URL url = new URL(urlString);
InputStream is = (InputStream)url.getContent()
0 0
0
Android Developer Room
19-07-2011 02:18
Quote:Original Posted By geek147
Misi suhu.

Ada yang ngerti gmn cara ngonvert image ke base64 g?
Biar bisa dimasukin ke dalam db. kebetulan ane make mysql sama php buat servernya.

Mungkin ada yg pernah bikin ? nuhun gan


Base64.encode(imageByteArray, Base64.DEFAULT);

emoticon-Big Grin
0 0
0
Android Developer Room
19-07-2011 08:06
Quote:Original Posted By kakus-ers
Base64.encode(imageByteArray, Base64.DEFAULT);

emoticon-Big Grin


itu imagenya mesti dikonvert ke bitmap dulu g gan ?

kodingan ane kyk gini nih :

Quote:

package code.encode.com;

import java.io.ByteArrayOutputStream;


import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.util.Base64;
import android.widget.TextView;

public class Encode extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView txt = (TextView)findViewById(R.id.textView1);
try{
Bitmap bm = BitmapFactory.decodeFile(
"a.jpg" );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object
byte[] b = baos.toByteArray();

b = Base64.encode(b, Base64.DEFAULT);
System.out.print(b.toString());
txt.setText(b.toString());
}
catch (Exception e) {
\t
\t \tSystem.out.println(e.toString());
\t \t\t
\t }
}

}




Kira2 salah dimana ya gan ? T.T
0 0
0
Halaman 59 dari 501
icon-hot-thread
Hot Threads
obrolan-hangat-logo
Obrolan Hangat
Mac Applications & Games
Copyright © 2021, Kaskus Networks, PT Darta Media Indonesia