001.
package
com.technotalkative.viewstubdemo;
002.
003.
import
java.io.IOException;
004.
import
java.io.InputStream;
005.
import
java.net.HttpURLConnection;
006.
import
java.net.MalformedURLException;
007.
import
java.net.URL;
008.
import
java.net.URLConnection;
009.
010.
import
android.app.Activity;
011.
import
android.content.Intent;
012.
import
android.graphics.Bitmap;
013.
import
android.graphics.BitmapFactory;
014.
import
android.graphics.BitmapFactory.Options;
015.
import
android.media.Image;
016.
import
android.os.Bundle;
017.
import
android.provider.MediaStore.Images;
018.
import
android.util.Log;
019.
import
android.widget.ImageView;
020.
import
android.widget.TextView;
021.
022.
public
class
Activity_Detail
extends
DashBoardActivity{
023.
024.
TextView Store_details,Store_names,Store_types;
025.
026.
027.
028.
@Override
029.
public
void
onCreate(Bundle savedInstanceState) {
030.
031.
super
.onCreate(savedInstanceState);
032.
setContentView(R.layout.detail_store);
033.
setHeader(getString(R.string.NearbyActivityTitle),
true
,
true
);
034.
035.
Intent intent = getIntent();
036.
final
String Storename = intent.getStringExtra(
"nameStore"
);
037.
Log.i(
"Detail name"
,
""
+Storename);
038.
039.
final
String URLImage = intent.getStringExtra(
"nameImage"
);
040.
Log.i(
"Detail IMG "
,
""
+URLImage);
041.
042.
final
String nameType = intent.getStringExtra(
"nameType"
);
043.
Log.i(
"nameType"
,
""
+nameType);
044.
045.
final
String store_detail = getIntent().getExtras().getString(
"store_detail"
);
046.
Log.i(
"store_detail"
,
""
+store_detail);
047.
048.
Store_details = (TextView)findViewById(R.id.textDetail);
049.
Store_names = (TextView)findViewById(R.id.textName);
050.
Store_types = (TextView)findViewById(R.id.textCatagory);
051.
052.
Store_details.setText(
""
+ store_detail);
053.
Store_names.setText(
""
+ Storename);
054.
Store_types.setText(
""
+ nameType);
055.
056.
057.
ImageView storeImg = (ImageView)findViewById(R.id.imageStore1);
058.
storeImg.setImageBitmap(fetchImage( URLImage ));
059.
060.
}
061.
062.
063.
064.
065.
066.
public
Bitmap fetchImage( String URLImage )
067.
{
068.
try
069.
{
070.
URL url =
new
URL( URLImage.trim() );
071.
InputStream input =
null
;
072.
URLConnection conn = url.openConnection();
073.
HttpURLConnection httpConn = (HttpURLConnection)conn;
074.
httpConn.setRequestMethod(
"GET"
);
075.
httpConn.setReadTimeout(
40000
);
076.
httpConn.connect();
077.
078.
if
(httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
079.
input = httpConn.getInputStream();
080.
}
081.
082.
083.
Bitmap bitmap = BitmapFactory.decodeStream(input);
084.
input.close();
085.
httpConn.disconnect();
086.
return
bitmap;
087.
088.
}
089.
catch
( MalformedURLException e ){
090.
Log.d(
"fetchImage"
,
091.
"MalformedURLException invalid URL: "
+ URLImage );
092.
}
catch
( IOException e ){
093.
Log.d(
"fetchImage"
,
"IO exception: "
+ e);
094.
}
catch
(Exception e){
095.
Log.d(
"fetchImage"
,
"Exception: "
+ e);
096.
}
097.
return
null
;
098.
}
099.
}