0

I know many of you will say "check your settings when creating the project," but I did. I checked and my physical device (Samsung S3) uses Android 4.3 and I set the minimum requirement to 2.2 and target to 4.3. I think it might be my code because I've been able to run other Android applications using the eclipse ADT emulator I just never tried it on an actual device and it just doesn't even show up in my emulator. Here is my java code:

package com.example.bitmapdisplay;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;

public class MainActivity extends Activity {


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


        try {
        URL req = new URL("http://i1.cpcache.com/product_zoom/617914535/dickbutt_2_mug.jpg?      side=Back&height=250&width=250&padToSquare=true");

        ImageView image = (ImageView) findViewById(R.id.ivImage);
        Bitmap mIcon_val= BitmapFactory.decodeStream(req.openConnection()
    .getInputStream()); 
        image.setImageBitmap(mIcon_val);

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

    }
    }

Here is my XML layout file:

<RelativeLayout 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"
    tools:context="${packageName}.${activityClass}" >

    <ImageView
        android:id="@+id/ivImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />


</RelativeLayout>

Here is my XML Manifest:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.bitmapdisplay"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.INTERNET" /> 

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />



    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

         <activity android:name="com.example.bitmapdisplay.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>
  • Can you post your LogCat? – heLL0 May 28 '14 at 23:58
  • The emulator can sometimes lose connection with Eclipse. When you execute your android app and the emulator starts up, you should see "Waiting for HOME" in the console – Stuartsoft May 29 '14 at 00:02
  • Looks like you're missing a `` node on your manifest. It's needed to let the package manager know which activity is your default one and whether it should be launchable from the app drawer. – Santa May 29 '14 at 00:11
  • But I thought the default was that if you don't specify it is always set to DEFAULT unless you have more than one activity (of course I could be wrong)? – Stickerbomby May 29 '14 at 00:14

2 Answers2

0

whether the message appears in the console messages like this example? :

uploading your.apk onto device '0123456789ABCDEF' installing your.apk starting activity

  • It just says : "[2014-05-29 02:01:36 - BitmapDisplay] Uploading BitmapDisplay.apk onto device 'emulator-5554' [2014-05-29 02:01:36 - BitmapDisplay] Installing BitmapDisplay.apk... [2014-05-29 02:02:50 - BitmapDisplay] Success! [2014-05-29 02:02:50 - BitmapDisplay] \BitmapDisplay\bin\BitmapDisplay.apk installed on device [2014-05-29 02:02:50 - BitmapDisplay] Done!" – Stickerbomby May 29 '14 at 00:05
  • 1
    add this to your manifest : change the activity ` ` – Muhammad Nafian Wildana May 29 '14 at 00:08
  • Thank you, but would you mind explaining why I'd do that? Because don't I already have and activity setup? – Stickerbomby May 29 '14 at 00:11
  • 1
    The `` node is needed to let the package manager know which activity is your default one and whether it should be launchable from the app drawer. – Santa May 29 '14 at 00:12
  • if you do not write the category, activity launcher will not shown in your application in your phone, this is example of warning in console if you not create it : [2014-05-29 07:07:38 - YourApp] No Launcher activity found! [2014-05-29 07:07:38 - YourApp] The launch will only sync the application package on the device! – Muhammad Nafian Wildana May 29 '14 at 00:15
  • It crashed as soon as I opened the application... Must be the code then – Stickerbomby May 29 '14 at 00:20
  • try this : [http://stackoverflow.com/questions/8992964/android-load-from-url-to-bitmap] (http://stackoverflow.com/questions/8992964/android-load-from-url-to-bitmap) – Muhammad Nafian Wildana May 29 '14 at 00:26
0

Need to look at the logCat for more info but one problem that i can see in your manifest is that you have intent-filters missing. Inside your application

android.intent.category.MAIN is given to the activity wich is going to launch at first.

Try this:

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

Add these two lines to your activity tab and this will tell android this is the main starting activity.

android_Muncher
  • 1,057
  • 7
  • 14