here is a code, i have a basic login screen and if username is correct it need to swiitch to AndroidTab.java view, i cant write a correct code for it any one can help ?
Code:
[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]btnLogin[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setOnClickListener([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] OnClickListener() {[/SIZE]
[LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464] @Override[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] public [/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onClick(View v) {[/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] // Check Login[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2] String username =[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]etUsername[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getText().toString();[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2] String password = [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]etPassword[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getText().toString();[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055] if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2](username.equals([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"User1"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) && password.equals([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"pass"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])){[/SIZE]
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0] lblResult[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Login successful."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE][/LEFT]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* ************************************[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]* ************************************[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f]
[SIZE=2][COLOR=#3f7f5f]* [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* CODE TO GO TO AndoidTab VIEW Class[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* [/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]* ************************************[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]**************************************/[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[/LEFT]
[SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE]
[LEFT][SIZE=2]} [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] {[/SIZE]
[LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]lblResult[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Login failed. Username and/or password doesn't match."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2] }[/SIZE]
[SIZE=2] }[/SIZE][/LEFT]
[SIZE=2]});[/SIZE][/LEFT]
(if u full code neccessery i can add it)
Look up Intent & startActivity(); there are alot of examples out there.
jug6ernaut said:
Look up Intent & startActivity(); there are alot of examples out there.
Click to expand...
Click to collapse
i know and im looking for an answer online too,
but atm i really could do with a quick fix lol
one learns nothing if everything is handed to them
With that said xD.
Code:
Intent myIntent = new Intent();
//being package name & activity name
myIntent.setClassName("jug6ernaut.lwp.tetris", "jug6ernaut.lwp.settings.ColorSettings");
startActivity(myIntent);
note that the activity will have to be identified in you manifest file.
also note that if you are not going to use your life first activity anymore you will probably want to remove it from the activity stack so that when you press the back button it doesnt reopen it.
Trying to run php script on my site.
If i put URL and name/value pair into a browser, the script runs and returns info from my database.
However, when I run HttpPost httppost = new HttpPost("http://www.mywebsite/myscript.php");
I get Unknown Host; this is most likely DNS and my namesevers should be getting setup.
So I put in the IP address of www.mywebsite..and it throws a Socket Exception, Permission Denied.
Any ideas? I tried adding android.permission.INTERNET on the Applications tab of Manifest.xml, but that gives me an error and won't even run the program.
Something like "l (pid=3228, uid=2000) requires android.permission.INTERNET" no idea what that's complaining about
Update to those that may encounter same problem....
Adding the permission via the Application tab wasn't correct. I manually added the line "<uses-permission android:name="android.permission.INTERNET" />" before the <application> tag in manifest.xml and it worked fine.
NOTE: I had tired that before and it still gave an error. I shut down my Mac Book Pro and restarted and it was ok...maybe a cache issue.
Hi,
I'm developing simple app that display images in WebView.
While coding i get problem with load data in WebView. When i try to load some data like:
Code:
String data = "<html><body><img src="http://xxxxxxxxxxx"/></body></html>"
WebView.loadData(data, "text/html", "utf-8");
the image can't be loaded because the link in src="" is redericting me to another page that contains not only image but full web page.
The example is: http://i1.kwejk.pl/site_media/obrazki/02491-77d715da62fe976.jpg
When i try to load this image it redirect me to that page: http://kwejk.pl/obrazek/02491
It's even working like that in Desktop Browser, Phone etc.
Is there any solution to disable redirecting to another page when loading image??
Please help.
Hello,
I'm trying to make an application that uses a webview to load a page containing a swf which should be populate with data loaded from a localfile.
The main idea, is that if I want to open that html from my computer directly, I should go to :
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
... and add the swf as a trusted file. If I copy the files inside tomcat, and start the tomcat, I can view thee swf with all data loaded
Now, in android I can't open that page to change the Global Security Settings, so I can't load the data. Do you have any idea how to do this? Or a workaround to this?
Ok, I see that no one has any idea.. But what about creating a tiny web server that returns that page? I think it should do the trick, but I can't find any tutorial about creating web servers in Android.. basically I need to open a port and return the html from @assets relative to what's after localhost : port. Do you know, or have a sample that I could use it as an example?
I need a way to search in StorageFiles with dynamically pattern, which comes from a TextBox. The directive "Windows.Storage.Search" doesnt exist in windows phone 8.1 runtime, as i saw. Now my question is, how can i do this in alternative way?
The only way to do it with WP 8.1 since Microsoft ALWAYS fails to implement the important things are to query using LINQ.
Ex:
Code:
var result = (await Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(x => txtBox.Text));
That's about all you can do pretty much. (Thanks Microsoft).
Thank you for the example. But it wont work for me, it shows me the following error(s):
Code:
A local variable named 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a 'parent or current' scope to denote something else
and
Code:
Cannot convert lambda expression to type 'string' because it is not a delegate type
Thats really odd from Microsoft, that they havent implementet the search function like in WinRT (Windows Store App).
The first error is pretty simple. You already have the variable named "x" and it would be very bad if compiler didn't give you that error.
Change the name of the variable to something else that you don't use in that scope and it will work.
And for second problem, try this one:
Code:
private List<string> Result()
{
var result = ((List<Windows.Storage.Search.CommonFileQuery>)Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).Where(x => x.ToString().Contains(txtBox.Text));
return result as List<string>;
}
private async Task<List<string>> ResultAsync()
{
return await Task.Run(() => Result()).ConfigureAwait(continueOnCapturedContext: false);
}
You should call ResultAsync method and get the result in this way:
Code:
List<string> myList = ResultAsync().Result;
That's not going to work. You can't cast a StorageFile as a string.
To fix my code (simple lambda typo)
Code:
var result = (await Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(txtBox.Text));
if(result.Any())
{
// Do shtuff
}
Also, you should never access the .Result of an async task because you never know if it completed yet.
Ok, first error is done, but the second error is still here
Code:
Cannot convert lambda expression to type 'string' because it is not a delegate type
You are missing the point of the TAP (Task Async Pattern).
Both main thread and async method will be in execution in the same time. When the async method finish his work, main thread will stop and catch the result trough the Result property.
TAP is the recommended way of asynchronous programming in C#. The only thing with TAP is to use ConfigureAwait method in non-console type of apps to avoid deadlock.
Sooner or later you will get the result from TAP method. Nothing will get in the conflict with the main thread.
Oh wait, @andy123456 I updated my response. I forgot String.Contains ISNT a lambda .
@Tonchi91, I know all about the TAP. I've been using it since it was CTP. I've seen the awkward situations with threading in WP .
Now... if he did
Code:
List<string> myList;
ResultAsync().ContinueWith(t=> { myList = t.Result; });
I wouldn't be worried .
Ok the errors are gone, but the debugger show me the following exception:
Code:
Value does not fall within the expected range
Is this search method case-sensitive? I tried with an exact input in the TextBox.
Hmmm. Let's see your full code.
its actually only for testing, so i added your code to a button (asnyc) and will show the output in a textBlock.
Code:
private async void buttonTest_Click(object sender, RoutedEventArgs e)
{
//Result();
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(textBox_test.Text));
if (result.Any())
{
// Do shtuff
textBlock_test.Text = result.ToString();
}
}
The error is coming from here
Code:
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName))
andy123456 said:
its actually only for testing, so i added your code to a button (asnyc) and will show the output in a textBlock.
Code:
private async void buttonTest_Click(object sender, RoutedEventArgs e)
{
//Result();
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName)).
Where(x => x.Name.
Contains(textBox_test.Text));
if (result.Any())
{
// Do shtuff
textBlock_test.Text = result.ToString();
}
}
The error is coming from here
Code:
var result = (await Windows.Storage.KnownFolders.CameraRoll.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName))
Click to expand...
Click to collapse
Oh Camera Roll.. You MIGHT need to have the capability to view the camera roll enabled. I forget what it's called, but you need a specific cap in order to view from there. Also, I would try to see if you can use a generic folder instead.
I would try Windows.Storage.ApplicationData.Current.LocalFolder.GetFilesAsync() as your method after the await just to test whether you can read correctly.
Yes but in wp8.1 runtime app, there arent caps anymore. The capability for access to the pictures is simply calles pictures library and is enabled. I have tested it as you said, but it gives me the same exception.
A quick tip: another way to do this is to use the Win32 C runtime API. You can, for example, use the FindFirst/NextFile functions (http://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx) which support searches using wildcards (* and ? characters in the first parameter). These functions are wrapped in my NativeLibraries classes, but are also just publicly available for third0party developers to call from their own C++ DLLs.
Alternatively, you can use the .NET System.IO.Directory class, which has functions like EnumerateFiles(String path, String searchPattern). This is probably the better way to do it, actually.
Of course, if you want these operations to not block the current thread, you'll need to explicitly put them in their own thread or async function.
EDIT: This also assumes you have read access to the relevant directories. You application data directory works fine, for example (you can get its path from the relevant StorageFolder object). Other directories that can be accessed via WinRT functions may go through a broker function instead of being directly readable.
The point is, that i have an array with filenames. Now i need the StorageFile files which contains these filenames. My idea was to search for these files and return the files as StorageFile, so i can work with these. Or is there a simpler / another way?
http://msicc.net/?p=4182 <-- try this
Thank you, i have already done this and its working. But how can i compare the Files to read, with already read files and take only the not yet read files?