forked from robinmanuelthiel/xamarinworkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fix resolves robinmanuelthiel#5. “Android App does not show profile images”
- Loading branch information
Moritz
authored and
Moritz
committed
Dec 11, 2016
1 parent
8ae9486
commit 9c0cdd8
Showing
7 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...with Xamarin.Forms/Code/Frontend/Xamarin.Forms/Conference.Forms.Droid/DroidHttpService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Conference.Frontend; | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Android.OS; | ||
|
||
[assembly: Xamarin.Forms.Dependency(typeof(Conference.Forms.Droid.DroidHttpService))] | ||
namespace Conference.Forms.Droid | ||
{ | ||
public class DroidHttpService : IHttpService | ||
{ | ||
private HttpClient httpClient; | ||
|
||
public DroidHttpService() | ||
{ | ||
// HTTPS Fix | ||
// see https://developer.xamarin.com/guides/cross-platform/transport-layer-security/ | ||
httpClient = new HttpClient(new Xamarin.Android.Net.AndroidClientHandler()); | ||
} | ||
|
||
public async Task<string> GetStringAsync(string url) | ||
{ | ||
// TEMP fix for NetWorkOnMainThread | ||
// see http://stackoverflow.com/questions/6343166/how-to-fix-android-os-networkonmainthreadexception | ||
// and http://www.androiddesignpatterns.com/2012/06/app-force-close-honeycomb-ics.html | ||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build(); | ||
StrictMode.SetThreadPolicy(policy); | ||
return await httpClient.GetStringAsync(url); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...Xamarin.Forms/Code/Frontend/Xamarin.Forms/Conference.Forms.Droid/EnvironmentVariables.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
XA_HTTP_CLIENT_HANDLER_TYPE=Xamarin.Android.Net.AndroidClientHandler |
3 changes: 2 additions & 1 deletion
3
...n.Forms/Code/Frontend/Xamarin.Forms/Conference.Forms.Droid/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-sdk android:minSdkVersion="15" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<application android:label="Conference.Forms.Droid"></application> | ||
</manifest> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters