Code help (website connection, media playback)

Put your problem here if it does not fit any of the other categories.

Code help (website connection, media playback)

Postby Nuladion » Mon Dec 15, 2008 11:39 pm

Hello everyone,
I'm trying to develop a prototype of an application in Android for my graduation project. I'm new to Java and Android and I'd like some help on some parts.

Could someone help me on my way in creating the following:
  • How to show a map with an overlay containing some waypoints and a line between them (like a route).
    I got the map part down, just can't seem to get any overlay showing.
  • How to make a connection between Android and a website, and how to send/retrieve text/media from it.
  • How to play media. Is there a default media player I can call from my application?

Some code snippets (or links to) would certainly help a lot, so I can build from there. I just don't really know where/how to start :)

Thanks in advance.

Regards,
Nul
Last edited by Nuladion on Thu Dec 18, 2008 7:24 pm, edited 1 time in total.
Nuladion
Developer
Developer
 
Posts: 26
Joined: Mon Jun 23, 2008 12:23 pm
Location: Maastricht, Netherlands

Top

Re: Code help

Postby Rahul » Tue Dec 16, 2008 10:41 am

Regarding your query to play media files you can visit this link

Click here






Nuladion wrote:Hello everyone,
I'm trying to develop a prototype of an application in Android for my graduation project. I'm new to Java and Android and I'd like some help on some parts.

Could someone help me on my way in creating the following:
  • How to show a map with an overlay containing some waypoints and a line between them (like a route).
    I got the map part down, just can't seem to get any overlay showing.
  • How to make a connection between Android and a website, and how to send/retrieve text/media from it.
  • How to play media. Is there a default media player I can call from my application?
Some code snippets (or links to) would certainly help a lot, so I can build from there. I just don't really know where/how to start :)

Thanks in advance.

Regards,
Nul
Rahul
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Wed Oct 01, 2008 11:16 am

Re: Code help

Postby Nuladion » Thu Dec 18, 2008 12:01 am

Rahul wrote:Regarding your query to play media files you can visit this link

Click here


Thanks a lot for your help, I will check that link!


I've managed to get an overlay on my map and put some markers on it. I tried a few tutorials and looked at some code examples to paint a line between them, but I cannot seem to get it to work.
Could anyone help me to paint a line between the two markers in the following code?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.guidokessels.MapItemizedOverlay;
  2.  
  3.  
  4.  
  5. import java.util.ArrayList;
  6.  
  7. import java.util.List;
  8.  
  9.  
  10.  
  11. import android.graphics.drawable.Drawable;
  12.  
  13. import android.os.Bundle;
  14.  
  15. import android.view.ViewGroup;
  16.  
  17. import android.widget.LinearLayout;
  18.  
  19. import android.widget.Toast;
  20.  
  21.  
  22.  
  23. import com.google.android.maps.GeoPoint;
  24.  
  25. import com.google.android.maps.ItemizedOverlay;
  26.  
  27. import com.google.android.maps.MapActivity;
  28.  
  29. import com.google.android.maps.MapController;
  30.  
  31. import com.google.android.maps.MapView;
  32.  
  33. import com.google.android.maps.OverlayItem;
  34.  
  35. import com.google.android.maps.MapView.LayoutParams;
  36.  
  37.  
  38.  
  39. public class MapWithOverlays extends MapActivity {
  40.  
  41.     // Points on the map.
  42.  
  43.     private GeoPoint pointCoord1 = new GeoPoint(50887955, 5981115);
  44.  
  45.     private GeoPoint pointCoord2 = new GeoPoint(50888201, 5982129);
  46.  
  47.    
  48.  
  49.     private MapView viewMap = null;
  50.  
  51.    
  52.  
  53.     @Override
  54.  
  55.     protected boolean isRouteDisplayed() {
  56.  
  57.         return false;
  58.  
  59.     }
  60.  
  61.    
  62.  
  63.     @Override
  64.  
  65.     protected void onCreate(Bundle pBundle) {
  66.  
  67.         super.onCreate(pBundle);
  68.  
  69.        
  70.  
  71.         // Set content view
  72.  
  73.         setContentView(R.layout.main);
  74.  
  75.        
  76.  
  77.         // Get map & toggle satellite.
  78.  
  79.         viewMap = (MapView) findViewById(R.id.map);
  80.  
  81.         viewMap.setSatellite(true);
  82.  
  83.        
  84.  
  85.         // Add zoom controls.
  86.  
  87.         LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.map_zoom);
  88.  
  89.         zoomLayout.addView(viewMap.getZoomControls(),
  90.  
  91.             new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
  92.  
  93.                 LayoutParams.WRAP_CONTENT));
  94.  
  95.        
  96.  
  97.         // Define marker
  98.  
  99.         Drawable defaultMarker = getResources().getDrawable(R.drawable.map_marker_red);
  100.  
  101.        
  102.  
  103.         // Specify marker bounds.
  104.  
  105.         defaultMarker.setBounds(0, 0, defaultMarker.getIntrinsicWidth(),
  106.  
  107.             defaultMarker.getIntrinsicHeight());
  108.  
  109.        
  110.  
  111.         // Add waypoints.
  112.  
  113.         viewMap.getOverlays().add(new MyOverlay(defaultMarker, pointCoord1, pointCoord2));
  114.  
  115.        
  116.  
  117.         // Get controller, move to first waypoint & set zoom level.
  118.  
  119.         MapController mapController = viewMap.getController();
  120.  
  121.         mapController.animateTo(pointCoord1);
  122.  
  123.         mapController.setZoom(18);
  124.  
  125.     }
  126.  
  127.    
  128.  
  129.     private class MyOverlay extends ItemizedOverlay<OverlayItem> {
  130.  
  131.         private List<OverlayItem> listPoints = new ArrayList<OverlayItem>();
  132.  
  133.        
  134.  
  135.         public MyOverlay(Drawable pMarker, GeoPoint pPoint1, GeoPoint pPoint2) {
  136.  
  137.                 super(pMarker);
  138.  
  139.            
  140.  
  141.             // Add waypoints.
  142.  
  143.             listPoints.add(new OverlayItem(pPoint1, "Title1", "Snippet1"));
  144.  
  145.             listPoints.add(new OverlayItem(pPoint2, "Title2", "Snippet2"));
  146.  
  147.            
  148.  
  149.             populate();
  150.  
  151.         }
  152.  
  153.        
  154.  
  155.         @Override
  156.  
  157.         protected OverlayItem createItem(int pIndex) {
  158.  
  159.             return listPoints.get(pIndex);
  160.  
  161.         }
  162.  
  163.        
  164.  
  165.         @Override
  166.  
  167.         protected boolean onTap(int pIndex) {
  168.  
  169.             Toast.makeText(MapWithOverlays.this,
  170.  
  171.                 "Text on Tap.",
  172.  
  173.                 Toast.LENGTH_SHORT).show();
  174.  
  175.            
  176.  
  177.             return true;
  178.  
  179.         }
  180.  
  181.        
  182.  
  183.         @Override
  184.  
  185.         public int size() {
  186.  
  187.             return listPoints.size();
  188.  
  189.         }
  190.  
  191.     }
  192.  
  193. }
Parsed in 0.065 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  
  4.  
  5. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  6.  
  7.         android:orientation="vertical"
  8.  
  9.         android:layout_width="fill_parent"
  10.  
  11.         android:layout_height="fill_parent">
  12.  
  13.        
  14.  
  15.         <TextView
  16.  
  17.                 android:id="@+id/label"
  18.  
  19.                 android:layout_width="wrap_content"
  20.  
  21.                 android:layout_height="wrap_content"
  22.  
  23.                 android:text="Test route"
  24.  
  25.                 android:height="26px"
  26.  
  27.                 android:padding="5px" />
  28.  
  29.  
  30.  
  31.         <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  32.  
  33.                 android:orientation="vertical"
  34.  
  35.                 android:layout_width="fill_parent"
  36.  
  37.                 android:layout_height="fill_parent" >
  38.  
  39.                
  40.  
  41.                 <com.google.android.maps.MapView
  42.  
  43.                         android:id="@+id/map"
  44.  
  45.                         android:layout_width="wrap_content"
  46.  
  47.                         android:layout_height="wrap_content"
  48.  
  49.                         android:apiKey="MY_API_KEY"
  50.  
  51.                         android:enabled="true"
  52.  
  53.                         android:clickable="true"
  54.  
  55.                 />
  56.  
  57.                
  58.  
  59.                 <LinearLayout android:id="@+id/map_zoom"
  60.  
  61.                         android:layout_width="wrap_content"
  62.  
  63.                         android:layout_height="wrap_content"
  64.  
  65.                         android:layout_alignParentBottom="true"
  66.  
  67.                         android:layout_centerHorizontal="true"
  68.  
  69.                 />
  70.  
  71.                
  72.  
  73.         </RelativeLayout>
  74.  
  75. </LinearLayout>
Parsed in 0.007 seconds, using GeSHi 1.0.8.4


Any help would be greatly appreciated!


Guido.
Nuladion
Developer
Developer
 
Posts: 26
Joined: Mon Jun 23, 2008 12:23 pm
Location: Maastricht, Netherlands

Postby alpesh_harsoda » Thu Dec 18, 2008 12:38 pm

hi Nuladion,
i have done the map application before.and i m giving you the source of gps application.in that i have put two circle on map and then join it.
try this.
Attachments
GPSDemo.rar
(74.28 KiB) Downloaded 157 times
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby Nuladion » Thu Dec 18, 2008 1:16 pm

alpesh_harsoda wrote:hi Nuladion,
i have done the map application before.and i m giving you the source of gps application.in that i have put two circle on map and then join it.
try this.


Thanks a lot! I will try it out!
Nuladion
Developer
Developer
 
Posts: 26
Joined: Mon Jun 23, 2008 12:23 pm
Location: Maastricht, Netherlands

Postby alpesh_harsoda » Thu Dec 18, 2008 1:20 pm

this is i have done it for the sdk 1.0 try it for that.
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Top

Postby Nuladion » Thu Dec 18, 2008 2:11 pm

alpesh_harsoda wrote:this is i have done it for the sdk 1.0 try it for that.


When I try to run it it says the following:
[2008-12-18 14:08:10 - GPSDemo] Android Launch!
[2008-12-18 14:08:10 - GPSDemo] adb is running normally.
[2008-12-18 14:08:10 - GPSDemo] No Launcher activity found!
[2008-12-18 14:08:10 - GPSDemo] The launch will only sync the application package on the device!
[2008-12-18 14:08:10 - GPSDemo] Only Syncing Application Package


I checked, but there is a launcher intent. The emulator does not run it though, nor does it show up in the program list.
Nuladion
Developer
Developer
 
Posts: 26
Joined: Mon Jun 23, 2008 12:23 pm
Location: Maastricht, Netherlands

Postby alpesh_harsoda » Thu Dec 18, 2008 2:49 pm

hi
but when i have run the project its run successfully in my ecllipse.
just the import the project in your ecllipse then try to run again.
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby Nuladion » Thu Dec 18, 2008 3:08 pm

alpesh_harsoda wrote:hi
but when i have run the project its run successfully in my ecllipse.
just the import the project in your ecllipse then try to run again.


That is exactly what I did. But I'll try again. Thanks for your help.

Edit: Nope, I cannot seem to get it to launch :/
Nuladion
Developer
Developer
 
Posts: 26
Joined: Mon Jun 23, 2008 12:23 pm
Location: Maastricht, Netherlands

Postby alpesh_harsoda » Thu Dec 18, 2008 3:13 pm

ok try...it will done.
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 22 guests