15,897,371 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13593129 (Top 20 by date)
Member 13593129
11-Jan-18 12:05pm
View
Ok. Thanks for your help.
Member 13593129
11-Jan-18 11:58am
View
I don't get the coord.
Member 13593129
11-Jan-18 11:53am
View
As you can see. In first one latitude, and in second one longitude.
Member 13593129
11-Jan-18 11:22am
View
From some reason it doesn't do that.Don't know what's the issue.
I did the same for YT videos, where I have URL stored on FB, and it works flawlessly.
Member 13593129
11-Jan-18 10:49am
View
Ok, I get that. How to change that, so that pulls lat and lng from Firebase, and not from bundle?
Member 13593129
11-Jan-18 10:24am
View
I have that already. And it works, the problems is that opens map with same location.
Member 13593129
11-Jan-18 10:20am
View
How do you think I should solve this?
Member 13593129
11-Jan-18 7:32am
View
Now everything works, except one thing. I have stored my coord(lat, lng) on Firebase, and the problem is on whatever item I clicked, it always opens same place(Anaheim), cause those coord are here:
i.putExtra("LATITUDE", 33.835293);
i.putExtra("LONGITUDE", -117.914505);
I tried to change that on this way, but it doesn't work:
@OnItemClick(R.id.lvTours)
public void onItemClick(int position) {
String t = ((Tours)lvTours.getAdapter().getItem(position)).getLat();
String tr = ((Tours)lvTours.getAdapter().getItem(position)).getLng();
Intent i = new Intent(getContext(), MapActivity.class);
i.putExtra("Lat", 33.835293);
i.putExtra("Lng", -117.914505);
i.putExtra(MapActivity.Lat, t);
i.putExtra(MapActivity.Lng, tr);
startActivity(i);
}
}
And in MapActivity:
Bundle bundle = getIntent().getExtras();
dLatitude = bundle.getDouble("Lat");
dLongitude = bundle.getDouble("Lng");
if (bundle.containsKey(Lat)) {
mTours = bundle.getString(Lat, Lng);
}
This is the last problem I have. After that, I won't bother you no more.
A big thanks for your help.
Member 13593129
10-Jan-18 11:36am
View
I was being a idiot. I forgot to put API_KEY, that's why it didn't work. Although, I have one more question.It works, it shows just one location, though.I want when I click on every item, to show other place. Cause I have 27 tours, and they weren't on same place. Do you have an idea how to do that?
Member 13593129
10-Jan-18 9:21am
View
It doesn't work. I get NP on "private double dLongitude = 0.0;" and "setContentView(R.layout.tours_coord);". I'll post how it looks now.
public class MapActivity extends FragmentActivity implements OnMapReadyCallback {
private double dLatitude = 0.0;
private double dLongitude = 0.0;
public static final String COORD = "coord";
private String mTours;
private GoogleMap mMap;
private GoogleMap.OnMapClickListener mCustomOnMapClickListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tours_coord);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.fGoogleMap);
mapFragment.getMapAsync(this);
Bundle bundle = getIntent().getExtras();
dLatitude = bundle.getDouble("LATITUDE");
dLongitude = bundle.getDouble("LONGITUDE");
if (bundle.containsKey(COORD)) {
mTours = bundle.getString(COORD);
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng latlng = new LatLng(dLatitude, dLongitude);
mMap.addMarker(new MarkerOptions().position(latlng).title("It was here"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(latlng));
this.mCustomOnMapClickListener = new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
MarkerOptions newMarkerOptions = new MarkerOptions();
newMarkerOptions.icon(BitmapDescriptorFactory.fromResource(R.mipmap.tour));
newMarkerOptions.title("Tour");
newMarkerOptions.snippet("It' was here!");
newMarkerOptions.position(latLng);
mMap.addMarker(newMarkerOptions);
}
};
}
}
@OnItemClick(R.id.lvTours)
public void onItemClick(int position) {
String t = ((Tours)lvTours.getAdapter().getItem(position)).getCoord();
Intent i = new Intent(getContext(), MapActivity.class);
i.putExtra("LATITUDE", 33.835293);
i.putExtra("LONGITUDE", -117.914505);
i.putExtra(MapActivity.COORD, t);
startActivity(i);
}
Member 13593129
10-Jan-18 5:32am
View
It's not intentional, but I'll try your code that you provided, and let you know.
Member 13593129
9-Jan-18 8:31am
View
I solve my problem. Thanks for the help.
Member 13593129
2-Jan-18 11:23am
View
I must have that class cause I'm finishing Android course, and my professor said that I need to have YT class.
Member 13593129
2-Jan-18 10:41am
View
I did it like this: lvTracks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + url));
Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + url));
// Intent intent = Intent.createChooser(appIntent, "Open With");
Intent i = new Intent(getApplicationContext(), YT_activity.class);
startActivity(i);
try {
context.startActivity(appIntent);
} catch (ActivityNotFoundException ex) {
context.startActivity(webIntent);
}
But I don't know how to getIntent in YT_Activity.class. And I want when user clicks on some track, to open the video of that track, not to open just one video on every click of different track.
Member 13593129
2-Jan-18 10:25am
View
It looks like this: "https://www.youtube.com/watch?v=VuDaPSdHQ5o"..
Yes, I have an Youtube app on my device.
Member 13593129
2-Jan-18 10:13am
View
All my URL's are on Firebase within Tracks(child).Like you can see in a method above lvTracks.setOnItemClickListener.
Member 13593129
28-Dec-17 10:03am
View
This is what I did:
@OnItemClick(R.id.lvTracks)
public void onItemClick(Context context) {
String id;
Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + id));
Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + id));
try
{
context.startActivity(appIntent);
}
catch (ActivityNotFoundException ex)
{
context.startActivity(webIntent);
}
I initialized id, but id at the first line of code says 'not initialized', and only way to fix it to say this: String id = null;.
And when I run my app, I get the same message I previously post.
I also tryied to do like this:
Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.track_fragment);
ButterKnife.bind(this);
lvTracks.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + id));
Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + id));
try
{
context.startActivity(appIntent);
}
catch (ActivityNotFoundException ex)
{
context.startActivity(webIntent);
}
}
});
And when I click on listview, it crushes and I get a bunch of errors...non related to the current problem.
Member 13593129
28-Dec-17 8:09am
View
Ok, I tryied that and this is what I get:Error:(131, 17) error: Unable to match @OnItemClick method arguments. (com.example.lordofsummer.metalapp.TracksActivity.onItemClick)
Parameter #1: android.content.Context
did not match any listener parameters
Parameter #2: java.lang.String
did not match any listener parameters
Methods may have up to 4 parameter(s):
android.widget.AdapterView<?>
android.view.View
int
long
These may be listed in any order but will be searched for from top to bottom.
Member 13593129
27-Dec-17 14:01pm
View
So, you say that I should put this method instead of my method onItemClick? I did that, and nothing is happening.When I click on track, and youtube doeesn' t open. I found an example of Youtube_Activity code. It looks like this:
public class Youtube_class extends YouTubePlayerSupportFragment {
private static final String currentVideoID = "id";
private YouTubePlayer yPlayer;
@BindView(R.id.frame_layout) FrameLayout frame_Layout;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
View view = inflater.inflate(R.layout.activity_yt_,container, false);
return view;
}
public static Youtube_class newInstance(String url) {
Youtube_class youtube_activity = new Youtube_class();
Bundle bundle = new Bundle();
bundle.putString("url", url);
youtube_activity.setArguments(bundle);
youtube_activity.init();
return youtube_activity;
}
private void init() {
initialize(Youtube_key.getAPI_KEY(), new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationFailure(YouTubePlayer.Provider arg0, YouTubeInitializationResult arg1) {
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
yPlayer = player;
yPlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
if (!wasRestored) {
yPlayer.loadVideo(getArguments().getString("url"), 0);
Youtube_class myFragment = Youtube_class.newInstance("video_id");
getFragmentManager().beginTransaction().replace(R.id.frame_layout, myFragment).commit();
}
}
});
}
/* public void onYouTubeVideoPaused() {
yPlayer.pause();
}*/
}
Member 13593129
27-Dec-17 11:17am
View
All my data are on Firebase, including url of every video.
Show More