I searched following issue in this site and found many suggestions,
but any solution don't solve my issue.
If anybody knows real solution, please guide me.
Thank you in advance !!!
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
Intent localIntent;
if (resultCode != RESULT_OK)
return;
switch(requestCode){
case SEARCH_ADDRESS_ACTIVITY :
if(resultCode == RESULT_OK){
final String address = data.getExtras().getString("data");
if (address != null) {
addressEditText.setText(address);
}
}
break;
:::::
I'm sorry.
In my case, I cannot see the text because of EditText's height is so narrow.
The EditText's hint got space(height) more, so the EditText area was not seen ;;;
Related
I am developing and app to demostrate how NFC works. My goal is to make and app that will work very similary to Android Beam. I am using Xamarin.Android. The goal is to type message to one device, press button and it should be send to another device with the same app where it should be shown. I have tried almost everything even the documentation but it seems like it doesnt work. Does anyone have any experience with this technology? Is this technology even available nowadays?
There is some of my code to get you an idea about what i am trying to do:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
SetContentView(Resource.Layout.activity_main);
mNfcAdapter = NfcAdapter.GetDefaultAdapter(this);
myButton.Click += (e, o) => {
mNfcAdapter.SetNdefPushMessageCallback(this, this);
mNfcAdapter.SetOnNdefPushCompleteCallback(this, this);
};
}
public NdefMessage CreateNdefMessage(NfcEvent e)
{
DateTime time = DateTime.Now;
var text = (time.ToString("HH:mm:ss") + message2);
NdefMessage msg = new NdefMessage(
new NdefRecord[] { CreateMimeRecord (
text, Encoding.UTF8.GetBytes (text))});
return msg;
}
private NdefRecord CreateMimeRecord(string mimeType, byte[] payload)
{
byte[] mimeBytes = Encoding.UTF8.GetBytes(mimeType);
NdefRecord mimeRecord = new NdefRecord(
NdefRecord.TnfMimeMedia, mimeBytes, new byte[0], payload);
return mimeRecord;
}
public void OnNdefPushComplete(NfcEvent e)
{
Toast.MakeText(this.ApplicationContext, "Message sent", ToastLength.Long).Show();
}
protected override void OnResume()
{
base.OnResume();
if (NfcAdapter.ActionNdefDiscovered == Intent.Action)
{
ProcessIntent(Intent);
}
}
protected override void OnNewIntent(Intent intent)
{
Intent = intent;
}
void ProcessIntent(Intent intent)
{
IParcelable[] rawMsgs = intent.GetParcelableArrayExtra(
NfcAdapter.ExtraNdefMessages);
NdefMessage msg = (NdefMessage)rawMsgs[0];
var textViewMsg = FindViewById<TextView>(Resource.Id.textViewMsg);
textViewMsg.Text = Encoding.UTF8.GetString(msg.GetRecords()[0].GetPayload());
}
Thank you all :)
OnNdefPushComplete and the whole Android Beam was deprecated and removed from Android 10
https://developer.android.com/reference/android/nfc/NfcAdapter.OnNdefPushCompleteCallback
If you want to do Device to Device NFC going forward then it should be possible with one phone doing Host Card Emulation (HCE) and the other using enableReaderMode
But Google recommend using Bluetooth or Wifi Direct as a more reliable replacement for Android Beam. One of the replacement methods Google provided was Android Nearby https://developers.google.com/nearby
When I am calling this function there is no image/string in _bitmap. In my application, I select image from the gallery and convert it to base64. I had debugged the app for the problem, so I found that the method BitmapFactory.decodeFile("image path") is returning null value even though the path which I am getting is totally fine.
private void _btnResimYolu_Click(object sender, System.EventArgs e)
{
var imageIntent = new Intent();
imageIntent.SetType("image/*");
imageIntent.SetAction(Intent.ActionGetContent);
StartActivityForResult(Intent.CreateChooser(imageIntent, "Select Image"), 0);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (resultCode == Result.Ok)
{
var imageView = FindViewById<ImageView>(Resource.Id.img1);
imageView.SetImageURI(data.Data);
_imageTest.Text = data.DataString;
}
}
private void _gonder_Click(object sender, System.EventArgs e)
{
string uriString = _imageTest.Text;
_bitmap = BitmapFactory.DecodeFile(uriString);
MemoryStream stream = new MemoryStream();
_bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
byte[] ba = stream.ToArray();
string bal = Base64.EncodeToString(ba, Base64.Default);
}
BitmapFactory.decodeFile() returning null
The problem is that your get the wrong image path, so the BitmapFactory.DecodeFile(uriString) always return null. The data.DataString in OnActivityResult is my device is :
[0:] data.Data = content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20171125_143057.jpg
Solution :
When you choose a picture, you should convert its Uri to a real path. You could refer to my answer : How to get actual path from Uri xamarin android. Then, modify your code like this :
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == Result.Ok)
{
var uri = data.Data;
//You could find the GetActualPathFromFile() method code in the above link I have post.
string path = GetActualPathFromFile(uri);
_imageTest.Text = path ;
System.Diagnostics.Debug.WriteLine("data.Data = " + data.Data);
System.Diagnostics.Debug.WriteLine("path = " + path);
}
}
The image path :
[0:] path = /storage/emulated/0/DCIM/Camera/IMG_20171125_143057.jpg
Then you could BitmapFactory.DecodeFile() to implement your function.
Update :
Please make sure you have the WRITE_EXTERNAL_STORAGE permission, since Android 6.0, you have to Requesting Permissions at Run Time.
I'm new to google dart and been trying to learn it for a day now. I'm pretty novice to programming in general and I'm trying to read the documentation; however, I feel a bit overwhelmed.
I would like to know the most proper method of creating a interaction for spacebar here key. When one would push spacebar, it would toggle between function void startwatch() , void resetwatch()
I believe this is the correct documentation page also documentation for keyboardEventController
void main() {
}
void startwatch() {
mywatch.start();
var oneSecond = new Duration(milliseconds:1);
var timer = new Timer.repeating(oneSecond, updateTime);
}
void resetwatch() {
mywatch.reset();
counter = '00:00:00';
}
Any further information needed I'll try to respond immediately. Thnk you so much for your help.
To listen to keyboard events and toggle between startwatch() and resetwatch():
void main() {
var started = false;
window.onKeyUp.listen((KeyboardEvent e) {
print('pressed a key');
if (e.keyCode == KeyCode.SPACE) {
print('pressed space');
if (started) {
resetwatch();
} else {
startwatch();
}
started = !started; // A quick way to switch between true and false.
}
});
}
window is an instance of Window class. It's automatically provided for you.
There's also a handy class called KeyEvent, which attempts to eliminate cross-browser inconsistencies. These inconsistencies are usually related to special keys.
Hi Friend's i want to show details when i click on this list field with image(location)means u take any lat long and show with it a image map.so please help me to solve this problem.
How is it possible please help me.
Thanks
on this link show the list field i am also create like this listfiled and when i click and show details with image map
How is it possible please help me.
Thanks
Here I am giving some example try this (assign index to each field in the list view). You can display your details in NewsScreen().
protected boolean navigationClick(int status, int time) {
int index;
System.out.println("CLICKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
index = this.getFieldWithFocusIndex();
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run() {
UiApplication.getUiApplication().pushScreen(new NewsScreen());
}
});
System.out.println("OUTPUTTTTTTTTTTTTTTT"+this.getFieldWithFocusIndex());
return true;
}
you could pass the image map String URI or bitmap byte to the other screen and show it
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run() {
UiApplication.getUiApplication().pushScreen(new NewsScreen(IMAGE MAP STRING));
}
});
My lwuit application is working fine on Blackberry Simulator while on device the application installs successfully, starts normally, but where am having issues is on network connection. Trying to access network I get 400 Bad Request message. I don't no what am doing wrong, my network connection code is as below:
public ConnectionRequest prepareConnection(String page, String progressMsg, final int request)
{
final ConnectionRequest conR = new ConnectionRequest()
{
public void readResponse(InputStream input) throws IOException {
StringBuffer sb = new StringBuffer();
int ch;
while((ch=input.read()) != -1)
sb.append((char)ch);
httpResponse(sb.toString().trim(), request);
}
};
conR.setUrl(NetworkHandler.getURL()+page);
conR.setDuplicateSupported(true);
Progress progress = new Progress(progressMsg, conR)
{
public void actionCommand(Command command)
{
if(command.getCommandName().equals("Cancel"))
conR.kill();
}
};
conR.setDisposeOnCompletion(progress);
return conR;
}
private void login(String code)
{
Container container = Display.getInstance().getCurrent();
if(!validateLogin(container))
{
showDialogMessage("Alert", "Please enter your user name and password!");
return;
}
NetworkManager.getInstance().start();
ConnectionRequest conR = prepareConnection(NetworkHandler.LOGIN_PAGE, "Authenticating...", RequestType.LOGIN);
Dialog dialog = conR.getDisposeOnCompletion();
conR.setPost(true);
conR.addArgument("u", getFieldValue(findTxtUserName(container)));
conR.addArgument("p", getFieldValue(findTxtPassword(container)));
conR.addArgument("c", code);
NetworkManager.getInstance().addToQueue(conR);
dialog.show();
}
public void onLoginForm_BtnLoginAction(Component c, ActionEvent event) {
login("");
}
Please I want you guys to help me out.
Thanks in Advance.
The login me
This usually indicates a problem in APN configuration on the device. Normally Blackberry app's workaround incorrect APN configurations automatically which is a pretty difficult thing to do. CodenameOne does that seamlessly but LWUIT does not.