|
how to add button in the of the menu item fragment of the navigation drawer so that when the user click on the button he is redirected to anther sub fragment but one issue here is I am using the android custom navigation drawer implementation below is my try
package com.example.entertainmentlab.ui.store;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import com.example.entertainmentlab.R;
import com.example.entertainmentlab.ui.setting.SettingViewModel;
public class StoreFragment extends Fragment {
private StoreViewModel StoreViewModel;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
StoreViewModel =
ViewModelProviders.of(this).get(StoreViewModel.class);
View root = inflater.inflate(R.layout.fragment_store, container, false);
final ImageView MusicButton = root.findViewById(R.id.music_btn);
MusicButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Fragment fragment = new BlankFragment();
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.nav_host_fragment_container, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}catch (Exception e ){
Toast.makeText(getActivity(), "erro "+e, Toast.LENGTH_SHORT).show();
}
}
});
return root;
|
|
|
|
|
So what exactly is the problem?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I have been trying FOREVER to get a simple Xamarin Forms app to call a Web API. I am running this Microsoft sample Xamarin.Forms - TodoREST - Code Samples | Microsoft Docs
The only change I made was the port number that the API uses. This line is in a constants file. The emulator uses the internal ip of 10.0.2.2:
public static string RestUrl = DeviceInfo.Platform ==
DevicePlatform.Android ?
"http://10.0.2.2:44300/api/todoitems/{0}" :
"http://localhost:44300/api/todoitems/{0}";
Here's the relevant code. The URI being passed is correct from the line above:
public async Task> RefreshDataAsync()
{
Items = new List();
Uri uri = new Uri(string.Format(Constants.RestUrl, string.Empty));
try
{
HttpResponseMessage response = await client.GetAsync(uri);
if (response.IsSuccessStatusCode)
{
string content = await response.Content.ReadAsStringAsync();
Items = JsonConvert.DeserializeObject>(content);
}
}
catch (Exception ex)
{
Debug.WriteLine(@"\tERROR {0}", ex.Message);
}
return Items;
}
It throws this exception:
{Java.Net.SocketException: Connection reset
at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in :0
at Java.Net.HttpURLConnection.get_ResponseCode () [0x0000a] in :0
at Xamarin.Android.Net.AndroidClientHandler+<>c__DisplayClass46_0.b__2 () [0x00000] in :0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:534
at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
--- End of stack trace from previous location where exception was thrown ---
at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.URL javaUrl, Java.Net.HttpURLConnection httpConnection, System.Threading.CancellationToken cancellationToken, Xamarin.Android.Net.AndroidClientHandler+RequestRedirectionState redirectState) [0x00372] in :0
at Xamarin.Android.Net.AndroidClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x002d0] in :0
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506
at TodoREST.RestService.RefreshDataAsync () [0x0006b] in C:\Projects\SandBox\Xamarin\Mirosoft Examples\Web Services\ToDoREST\TodoREST\Data\RestService.cs:30
--- End of managed Java.Net.SocketException stack trace ---
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:139)
at com.android.okhttp.okio.Okio$2.read(Okio.java:136)
at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
at com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.android.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
at com.android.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:737)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:609)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:471)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:538)
}
Can anyone help? All I want is to call into a Rest API can get data back.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Have you allowed traffic to that port in the Windows Firewall?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Do I need to do that on my Dev PC using the Xamarin Forms emulator?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
I opened the port, and get the same error
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
When I try to play videos saved on my Google Drive, in my Google Pixel 4a. I keep getting the error “Whoops! there was a problem playing this video”. I have tried some basic troubleshooting with no result. If anyone has any suggestions, please help me out.
|
|
|
|
|
Hello, am a back-end node js developer, am working with a friend in a project, and we are looking for someone with experience in android development.
We are working with some really cool technologies and if you are interested I would love to give you a tour of the project.
At the moment this is not a payed position, but could lead to pay.
This project would look great in any resume and will give you really good experience with the development process in a group.
Reply for a tour of the project
|
|
|
|
|
hit me up at nathanalbertwallace@gmail.com .. l
|
|
|
|
|
Hi everybody, I would like to know which laptop model is suitable for Android Development.
|
|
|
|
|
Any laptop that has a reasonable amount of memory (at least 8 Gb), and an i5 or above processor should be OK.
|
|
|
|
|
Please give me detials information. I am now confused which one has to be bought. 
|
|
|
|
|
I gave you details in my previous message. What part did you not understand?
|
|
|
|
|
Buy what you can afford.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
|
Thanks bro. 
|
|
|
|
|
Hide Copy Code
i want to create a simple login app in android studio in that i want to fetch first time username and password from local database sqlite and after that when we log in then the imei number of device can store in database...then when we try to log in next time it will login through only that imei number
|
|
|
|
|
So what exactly is the problem with doing this?
|
|
|
|
|
You have already posted this in QA:
Creation of android application[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
And in the Mobile forum below.
|
|
|
|
|
Today I come to you with one question - I am currently creating an Android application that works with the firestore and implemented a class that checks the account type. Everything works fine, however I would now like to get the value of "typeOfAcc" from this class in a different class as it will be the path to my document in the database, however, there is one condition - the path must be downloaded only after the data is downloaded from the database and based on it it will be determined whether the account type should be changed to "Trainers". Anyone have any idea? All my attempts so far have ended with the second class just getting this string before changing its value, resulting in no access to data. Checking the logs, everything is fine, the value changes, but unfortunately after getting the value. Thanks in advance for your help!
```
public class UserValid
{
String typeOfAcc = "Podopieczni";
FirebaseFirestore fStore;
FirebaseAuth fAuth;
DocumentReference documentReference;
List itemList = new ArrayList<>();
String userID;
public UserValid()
{
Log.d("TAG", "Błąd, wybrano konstruktor bez argumentów");
}
public UserValid(FirebaseAuth fAuth, FirebaseFirestore fStore)
{
userID = fAuth.getCurrentUser().getUid();
this.fAuth = fAuth;
this.fStore = fStore;
documentReference = fStore.collection("Podopieczni").document(userID);
readData(new FirestoreCallback()
{
@Override
public void onCallback(List<String> list)
{
if(itemList.get(0) == null)
{
typeOfAcc="Trenerzy";
Log.d("TAG", itemList.toString());
}
}
});
}
private void readData(FirestoreCallback firestoreCallback)
{
documentReference.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful())
{
String itemName = task.getResult().getString("Imie");
itemList.add(itemName);
firestoreCallback.onCallback(itemList);
}
}
});
}
private interface FirestoreCallback
{
void onCallback(List<String> list);
}
}
```
|
|
|
|
|
Member 15037009 wrote: ...I would now like to get the value of "typeOfAcc" from this class in a different class... If it's a peer class, can you store it in a preference? The "receiving" class can monitor any changes to the preference and only do something when it changes.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
<string>[{"UserId":"1","Usercode":"ADMIN","Password":"123"},
{"UserId":"2","Usercode":"Ravi","Password":"ravi"}]</string>
I have one question if I want to login with both user code and password which logic I should apply.
|
|
|
|