|
Hi everybody,
I'm trying to get my android app to communicate with the standard ASP.net System.Web.ApplicationServices.AuthenticationService Web Service. For debugging purposes, I'm hosting the service locally and starting it from VS 2013. When I use the WCF Test Client, everything works like a charm, yet when trying to connect from the android emulator, I'm getting a code 400: Bad Request - Invalid Hostname. Since the WCF Test Cline can reach the service an I'm aware that I need to use 10.0.2.2:50816 instead of localhost:50816, I'm totally clueless as to why the host is invalid.
Here's the relevant lines from my web.config:
<system.web.extensions>
<scripting>
<webServices>
<authenticationService enabled="true" requireSSL="false" />
</webServices>
</scripting>
</system.web.extensions>
<system.serviceModel>
<services>
<service behaviorConfiguration="AuthenticationServiceBehaviors" name="System.Web.ApplicationServices.AuthenticationService">
<endpoint address="" contract= "System.Web.ApplicationServices.AuthenticationService"
binding="basicHttpBinding"
bindingConfiguration = "userHttps"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
<service behaviorConfiguration="ShinergyAdmin.services.MobileServiceBehavior" name="ShinergyAdmin.services.MobileService">
<endpoint address="" binding="basicHttpBinding" contract="ShinergyAdmin.services.IMobileService">
<identity>
<dns value="host" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="userHttps">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
This is my client-side invokation:
private static final String NAMESPACE = "http://asp.net/ApplicationServices/v200/";
private static String URL="http://10.0.2.2:50816/services/AuthService.svc?wsdl";
private static final String METHOD_NAME = "Login";
private static final String SOAP_ACTION = "\"http://asp.net/ApplicationServices/v200/AuthService.svc/Login\"";
public String ValidateUser(String username, String password){
SoapSerializationEnvelope envelope = null;
SoapObject request = null;
HttpTransportSE httpTransportSE = null;
try {
request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("username", username);
request.addProperty("password", password);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
httpTransportSE = new HttpTransportSE(URL, 27000);
httpTransportSE.debug = true;
httpTransportSE.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
httpTransportSE.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
String textResult = result.toString();
Log.i("textResult", textResult);
return textResult;
} catch (Exception e) {
e.printStackTrace();
}finally{
Log.i(getClass().getSimpleName(),"requestDump : "+httpTransportSE.requestDump);
Log.i(getClass().getSimpleName(),"responseDump : "+httpTransportSE.responseDump);
}
return "Failure to Login";
}
This is what I send (i.e., my request dump):
="1.0"="utf-8"<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://www.w3.org/2003/05/soap-encoding" xmlns:v="http://www.w3.org/2003/05/soap-envelope"><v:Header /><v:Body><Login xmlns="http://asp.net/ApplicationServices/v200/" id="o0" c:root="1"><username i:type="d:string">Username</username><password i:type="d:string">Password</password></Login></v:Body></v:Envelope>
and finally, this is the response dump:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>
I absolutely can't find out where that error is. Frustration levels are constantly rising here, so any help is highly appreciated!
|
|
|
|
|
My Database Helper Code is Here
public class DataHelper extends SQLiteOpenHelper {
public static final String DB_NAME="myDb";
public static final String Table_Pro="student";
public static final String Create_Pro="Create table if not exists "+Table_Pro+"(id integer primary key autoincrement,pname not null unique,age int,qual text)";
public static final String Delete_Pro="Drop table if exists "+Table_Pro;
public DataHelper(Context context) {
super(context, DB_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(Create_Pro);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(Delete_Pro);
onCreate(db);
}
public void insertProvince(String pname,int age,String qual)
{
SQLiteDatabase db=this.getWritableDatabase();
db.beginTransaction();
ContentValues values;
try
{
values=new ContentValues();
values.put("pname",pname);
values.put("age",age);
values.put("qual",qual);
db.insert(Table_Pro, null, values);
db.setTransactionSuccessful();
}catch (Exception e)
{
e.printStackTrace();
}
finally {
db.endTransaction();
db.close();
}
}
public ArrayList<String> getAllProvinces()
{
ArrayList<String> list=new ArrayList<String>();
SQLiteDatabase db=this.getReadableDatabase();
db.beginTransaction();
try
{
String selectQuery = " SELECT * FROM "+ Table_Pro;
Cursor cursor=db.rawQuery(selectQuery,null);
if(cursor.getCount()>0)
{
while (cursor.moveToNext())
{
String pname=cursor.getString(cursor.getColumnIndex("pname"));
list.add(pname);
}
}
db.setTransactionSuccessful();
}catch (Exception e)
{
e.printStackTrace();
}
finally {
db.endTransaction();
db.close();
}
return list;
}
public Cursor getAllData()
{
SQLiteDatabase db = getReadableDatabase();
Cursor res=db.rawQuery("select * from "+Table_Pro,null);
return res;
}
}
Main Activity is here
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
DataHelper dataHelper=new DataHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dataHelper.insertProvince("John",24,"Btech");
dataHelper.insertProvince("Bob",25,"Mtech");
dataHelper.insertProvince("Rock",30,"MBA");
dataHelper.insertProvince("Alice",45,"MCA");
dataHelper.insertProvince("Strike",40,"Masters");
ArrayList<String> listpro=dataHelper.getAllProvinces();
Spinner sp=(Spinner)findViewById(R.id.spinner_data);
sp.setOnItemSelectedListener(this);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,R.layout.spinner_layout,R.id.txt,listpro);
sp.setAdapter(adapter);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String label = parent.getItemAtPosition(position).toString();
Toast.makeText(parent.getContext(), "Welcome: " + label,
Toast.LENGTH_LONG).show();
Cursor res = dataHelper.getAllData();
if (res.getCount() == 0) {
showMessage("Error", "Nothing Found");
return;
}
StringBuffer buffer = new StringBuffer();
while (res.moveToNext()) {
buffer.append("age: " + res.getString(2) + "\n");
buffer.append("Qualification: " + res.getString(3) + "\n\n");
showMessage("Data", buffer.toString());
}
}
public void showMessage(String title,String Message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(Message);
builder.show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}
From there i have to get the age and qualification of selected name or person
but this code gives all persons age and qualification
Can You please help me to get out from here
Thank You a lot
modified 9-Feb-16 1:51am.
|
|
|
|
|
Your SELECT statement is requesting all records. If you only want certain ones then add a qualifying clause.
|
|
|
|
|
How about something like:
Cursor res = dataHelper.getAllData(position);
...
public Cursor getAllData(int position)
{
SQLiteDatabase db = getReadableDatabase();
Cursor res=db.rawQuery("select * from "+Table_Pro+" where id="+position,null);
return res;
} But that seems rathger silly when the data has already been retrieved into listpro . Why not:
String s = listpro.get(position); Of course you'd have to modify getAllProvinces() to store more than just an array of String types.
"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
modified 10-Feb-16 8:17am.
|
|
|
|
|
I've downloaded TutorialObjectTracking-master and i ran it using android studio and i built apk application, then when i ran it on the mobile i get ' ObjectTracking has stopped'
any help pleaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaase!!!!!!!
|
|
|
|
|
Member 12259984 wrote:
any help pleaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaase!!!!!!! Use the debugger.
"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
|
|
|
|
|
so????????????????????????????
|
|
|
|
|
Please put some proper details in your question. We have no idea what this program is or what it is doing.
|
|
|
|
|
i downloaded this :
Object Tracking on Android and Desktop
from:
[^]
i download the source code and i rebuilt the application but it is not working on the mobile , always i get " has stopped"
|
|
|
|
|
Sorry, but that tells us nothing of any use. We cannot guess what is happening on your system.
|
|
|
|
|
tell me how i can make this project work ?
iam using android studio.
|
|
|
|
|
No idea, try asking the author of the article.
|
|
|
|
|
Member 12259984 wrote: tell me how i can make this project work ? By removing the error(s).
"How do I do that?" you ask.
"Use the debugger to step through the code until you find the offending statement(s)," we all respond.
Then you ask, "So will that help me to narrow the problem down to just a handful of lines, or maybe a specific function?"
"Yes!" we reply in unison.
"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
|
|
|
|
|
thats the problem i got no errors in building the app ,
but still not working on mobile
|
|
|
|
|
Member 12259984 wrote: but still not working on mobile So use the debugger to step through the code.
"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 would like to Insert a text and Images in edit text as Note app in android Mobiles.Can any one suggest me to do that.
thanks in advance...
|
|
|
|
|
Tirumaleswara Reddy.K wrote: ...Note app in android... Which Note app?
"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
|
|
|
|
|
Notes app in android or iOS phones which includes Text and Images in same Notes
|
|
|
|
|
You would need to add your items to the not dynamically, by having some sort of canvas type container as the note. Then, when the user starts typing text you create an edit box which adds the text to the canvas. When the user indicates they want to add an image (by menu action perhaps) you add that to the canvas in a picture control.
|
|
|
|
|
My app crashes always when displaying listview with youtube thumbnail. I've created this app with AsyncTask,in doInBackground i'm fetching youtube video id and title which is in json... Then in onPostExecute i'm inflating my youtube view layout with customadapter and adding thumbnail for each list items in listview. But my app crashes always when doing this process... I used this listview with youtube thumbnail without getting title and video id from json(I did normal string array of title and video id,so there is no problem with my custom adapter.it works fine)I heard that if an app delay to get views for 5 secs,it'll automatically crashes... Is it true ? and Please help me what to do for this issue.. I'm new to Android...
|
|
|
|
|
An application crashes when the code you wrote is wrong...However we can not say what wrong with it if we can't see it...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
MainActivity
protected void onPostExecute(Integer result){
if(result == 1){
Toast.makeText(getApplicationContext(),"Result = 1",Toast.LENGTH_SHORT).show();
if(progressDialog.isShowing()){
progressDialog.dismiss();
}
Toast.makeText(getApplicationContext(),"onPostExecute",Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),VideoID[0],Toast.LENGTH_SHORT).show();
CustomAdapter customAdapter = new CustomAdapter(context,Title,VideoID);
listView.setAdapter(arrayAdapter);
CustomAdapter
public CustomAdapter(Activity context,String[] Title,String[] VideoID){
super(context,R.layout.activity_main,VideoID);
this.context = context;
this.Title = Title;
this.VideoID = VideoID;
}
@Override
public View getView(final int position,View convertView,ViewGroup parent){
View ListItemView = convertView;
if (convertView == null){
LayoutInflater inflater = context.getLayoutInflater();
ListItemView = inflater.inflate(R.layout.youtubethumbnail_loader,null,false);
}
youTubeThumbnailView = (YouTubeThumbnailView)ListItemView.findViewById(R.id.youtubethumbnailviewnew);
youTubeThumbnailView.initialize(Config.API_KEY, new YouTubeThumbnailView.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubeThumbnailView thumbnailView, YouTubeThumbnailLoader thumbnailLoader) {
Toast.makeText(context,"Success initialization",Toast.LENGTH_SHORT).show();
youTubeThumbnailLoader = thumbnailLoader;
thumbnailLoader.setOnThumbnailLoadedListener(new YouTubeThumbnailLoader.OnThumbnailLoadedListener() {
@Override
public void onThumbnailLoaded(YouTubeThumbnailView youTubeThumbnailView, String s) {
Toast.makeText(context, "Welcome to ShortFilmy", Toast.LENGTH_SHORT).show();
}
@Override
public void onThumbnailError(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader.ErrorReason errorReason) {
Toast.makeText(context, "Failed to load thumbnail", Toast.LENGTH_SHORT).show();
}
});
thumbnailLoader.setVideo(VideoID[position]);
}
@Override
public void onInitializationFailure(YouTubeThumbnailView youTubeThumbnailView, YouTubeInitializationResult youTubeInitializationResult) {
Toast.makeText(context,"Failed to initialize",Toast.LENGTH_SHORT).show();
}
});
textView = (TextView)ListItemView.findViewById(R.id.textViewnew);
textView.setText(Title[position]);
return ListItemView;
}
}
Here,my customadapter is working fine when i used without asynctask but if I call customadapter class in asynctask(onPostExecute method) it'll force close my app. I googled a lot about this but i didn't know what to do for this.. But I heard that every app wants to view the widgets or anything within 5 secs in UI thread otherwise our app got crashed.So you guys wanna help me out...
|
|
|
|
|
Member 12263477 wrote: I googled a lot about this Did you try some debugging of your application? You need to identify where the crash occurred and what were the circumstances at the time. Only then will you be able to start figuring out why it crashed.
|
|
|
|
|
Help guys, I don't know how to inflate youtubethumbnailview layout and to add it in list items. I'm fetching video id and title from json... If anyone have source code for this ??? Please help me. Thanks in advanced
|
|
|
|
|
Typically, you inflate entire XML file for that view. I have never used this, but I think it would be used in a layout (RelativeLayout or LinearLayout), just like any other control.
From the following blog, the code would be something like this:
<LinearLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/thumbnailview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Then, you can inflate it using any LayoutInflater object, get it using getLayoutInflater() .
Android Coding: Display YouTubeThumbnailView of YouTube Android Player API[^]
https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeThumbnailView?hl=en
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|