I'm trying to make an application which can communicate with android studio, but IntelliJ plugin SDK is not giving me enough option to build the features that I want, so I'm thinking about trying a different approach to create a separate windows application for functionality but as application needs to know the project folder that is currently opened with android studio, I'm trying to search the same from 4-5 days but haven't found anything helpful if this is possible to read folder location of open project in android studio with a different application please help me, if there is some way that building plugin that can send location to external application please tell me.
Thank you
Just manage to achieve the same with WPF, still don't know if electron can do it or not
if someone is finding the answer for this here's my approach, not the best and final but just figured out how I can do it make sure you will optimize code before implementation
private void Button_Click(object sender, RoutedEventArgs e)
{
var allProcesses = Process.GetProcesses();
String data = "";
for(int a =0; a < allProcesses.Length; a++)
{
Console.WriteLine(data);
if (allProcesses[a].MainWindowTitle.Contains("Android"))
{
Console.WriteLine(data);
data = allProcesses[a].MainWindowTitle;
if(data.Contains("["))
{
data = data.Substring(data.IndexOf("["));
data= data.Substring(0, data.IndexOf("]") + 1);
data = data.Replace("[", "");
data = data.Replace("]", "");
Console.WriteLine(data);
MessageBox.Show(data);
return;
}
else
{
MessageBox.Show("Project is not open in Android Studio");
return;
}
}
}
MessageBox.Show("Android Studio Not Running");
return;
}
Related
I am using Xamarin.Forms and written the code to download the file for the iOS
platform. It is downloading the file successfully without any error. But after downloading it, I am not able to find the downloaded file in my apple device.
During debugging I found that it is showing
/var/mobile/Containers/Data/Application/1234567A-B8CD-9EF9-C850-9G73587DC7C/Documents/XF_Downloads/hausmann_abcd.jpg
path. So at which location file get saved? below is the image for the same.
I have written below code for this
public class IosDownloader : IDownloader
{
public event EventHandler<DownloadEventArgs> OnFileDownloaded;
public void DownloadFile(string url, string folder)
{
string pathToNewFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), folder);
Directory.CreateDirectory(pathToNewFolder);
try
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
string pathToNewFile = Path.Combine(pathToNewFolder, Path.GetFileName(url));
webClient.DownloadFileAsync(new Uri(url), pathToNewFile);
}
catch (Exception ex)
{
if (OnFileDownloaded != null)
OnFileDownloaded.Invoke(this, new DownloadEventArgs(false));
}
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
if (e.Error != null)
{
if (OnFileDownloaded != null)
OnFileDownloaded.Invoke(this, new DownloadEventArgs(false));
}
else
{
if (OnFileDownloaded != null)
OnFileDownloaded.Invoke(this, new DownloadEventArgs(true));
}
}
}
When a file is saved on an application it is a temporary url within the app's sandbox. To make this image file be publicly accessible through Apple's Photos, You'll have to use native code to do a request to add a new PHImageAsset to the photos library.
In forms you would need to access the native frameworks and therefore run native code. There are plenty of examples of doing this online if you don't know how to already. But here is an introduction if you want to run native code within a shared code framework. https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction
Here is a sample of taking that temp file URL and saving it to Photos Framework once you can code w/ native Xamarin.iOS frameworks:
public void AddImageUrlToPhotosLibrary(string urlToSaveToPhotos)
{
PHPhotoLibrary.SharedPhotoLibrary.PerformChanges(() => {
//This is bound to native https://developer.apple.com/documentation/photokit/phassetchangerequest/1624060-creationrequestforasset
//Parameter is an NSURL of path to image.
PHAssetChangeRequest.FromImage(new NSUrl(urlToSaveToPhotos));
}, (completed, error) => {
if (completed)
{
if (error != null)
{
Console.WriteLine($"Failed saving image asset {error.LocalizedDescription}");
} else
{
Console.WriteLine($"Successfully saved image to photos library.");
}
}
});
}
I am not able to find the downloaded file in my apple device.
If you use a simulator, you can directly find the folder in the mac by entering the path in the
your mac --> select Finder --> Then open the Go menu --> Click Go to Folder as I described in this thread:
Where can I find the MyDocuments folder on iPhone Simulator?
If you installed the app in a real device. You can browse the file in
Xcode --> Devices and Simulators --> download container as described in this thread:
Browse the files created on a device by the iOS application I'm developing, after downloading the container, you can right click it and choose Show Package Contents. Then you can see the folders.
You can also access the file by the path in the project.
I am reading this documentation/article from Microsoft on how to Distribute Mobile apps with app center. The problem is I really don't understand how to implement this. I have a app on app center (Android) I want to implement mandatory update so that I can eliminate the bugs of the previous version. I tried to distribute the app with mandatory update enabled and it is not working. How can I fix this?
https://learn.microsoft.com/en-us/appcenter/distribution/
Here is what I did I added this code on my App.xaml.cs (XAMARIN FORMS PROJECT):
protected override void OnStart ()
{
AppCenter.Start("android={Secret Code};", typeof(Analytics), typeof(Crashes), typeof(Distribute));
Analytics.SetEnabledAsync(true);
Distribute.SetEnabledAsync(true);
Distribute.ReleaseAvailable = OnReleaseAvailable;
}
bool OnReleaseAvailable(ReleaseDetails releaseDetails)
{
string versionName = releaseDetails.ShortVersion;
string versionCodeOrBuildNumber = releaseDetails.Version;
string releaseNotes = releaseDetails.ReleaseNotes;
Uri releaseNotesUrl = releaseDetails.ReleaseNotesUrl;
var title = "Version " + versionName + " available!";
Task answer;
if (releaseDetails.MandatoryUpdate)
{
answer = Current.MainPage.DisplayAlert(title, releaseNotes, "Download and Install");
}
else
{
answer = Current.MainPage.DisplayAlert(title, releaseNotes, "Download and Install", "Ask Later");
}
answer.ContinueWith((task) =>
{
if (releaseDetails.MandatoryUpdate || (task as Task<bool>).Result)
{
Distribute.NotifyUpdateAction(UpdateAction.Update);
}
else
{
Distribute.NotifyUpdateAction(UpdateAction.Postpone);
}
});
return true;
}
And here is what I added on my MainActivity.cs(ANDROID PROJECT):
AppCenter.Start("{Secret Code}", typeof(Analytics), typeof(Crashes), typeof(Distribute));
Looking at this App Center documentation here for Xamarin Forms -
You can customize the default update dialog's appearance by implementing the ReleaseAvailable callback. You need to register the callback before calling AppCenter.Start
It looks like you need to swap your current ordering to get in-app updates working.
There could be a lot of different reasons as to why they are not working. As you can see in the Notes here and here,
Did your testers download the app from the default browser?
Are cookies enabled for the browser in their settings?
Another important point you'll read in the links, is that the feature is only available for listed distribution group users. It is not for all your members. You could use a simple version checker for your purpose instead or you could use a plugin.
I am trying to create client side app using C# for BluetoothLE in VisualStudio 2015 on Windows-10 laptop.
I have problem using Windows.Devices.Bluetooth.GenericAttributeProfile, the issue is my code has compile error saying GattDeviceServicesResult can not be found.
-> I have added package UwpDesktop 10.0.14393.3 by Valdimir Postel... (before installing this even "using Wndows.Devices.Bluetooth" was not working)
-> Then I added SDK, windows Kit that was recommended by VisualStudio when I tried to open one of the example (So I accept the recommendation to build that project and VS installed packages of around 9GB)
-> now I can use some of the Bluetooth api's I can scan and connect to a BLE device, but I can not use classes to deal with services and characteristics because GattDeviceServicesResult and GattCharacteristicsResult types are not found. Although these are mentioned on MSDN website
-> searching in forums I came to know I need to add one more reference System.Runtime.WindowsRuntime.dll, I browsed to proper folder through add reference utility of VS, I am trying to add this and it does nothing, after I select the dll and click 'Add' just nothing happens. (Add reference is not adding this dll).
Just for example if I select some other dll and try to add, that works fine!
Could somebody please help me with this,
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Bluetooth.Advertisement;
Int16 uuid_count = 0;
BluetoothLEAdvertisement[] ble_adv = new BluetoothLEAdvertisement[5];
BluetoothLEAdvertisementReceivedEventArgs[] ble_received_adv = new BluetoothLEAdvertisementReceivedEventArgs[5];
BluetoothLEDevice bluetooth_LE_Device;
GattDeviceServicesResult result_service;// This line does not compile
//Error: CS0246 the type name 'GattDeviceServicesResult ' could not be found
// I am adding reference to "System.Runtime.WindowsRuntime" as mentioned in some solutions
// the reference does not seems to be added at first when I click add button, but I can see the reference dll being mentioned in solution explorer (assuming it's been added)
// using this to scan available devices
private void scann_ble()
{
var watcher = new BluetoothLEAdvertisementWatcher();
watcher.Received += Watcher_Received;
watcher.AdvertisementFilter.Advertisement.ServiceUuids.Clear();
watcher.Start();
while (true)
{
Thread.Sleep(10000);
break;
}
watcher.Stop();
}
// receiver event to collect addresses of available devices
private void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
bool update_adv = true;
Int16 i = 0;
if(uuid_count < 5)
{
if (uuid_count > 0)
{
while (i < uuid_count)
{
if (ble_received_adv[i].BluetoothAddress == args.BluetoothAddress)
update_adv = false;
i++;
}
}
if(update_adv != false)
ble_received_adv[uuid_count++] = args;
}
}
// now connecting and checking available services
// as per "https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client"
private async void BLE_connect_button_Click(object sender, EventArgs e)
{
int i = 0;
i = BLE_device_grid_view.CurrentCell.RowIndex; // getting index from item selected in gridView
bluetooth_LE_Device = await BluetoothLEDevice.FromBluetoothAddressAsync(ble_received_adv[i].BluetoothAddress);
// Connection works fine, I can see it on my peripheral device
//get services - This is not working
result_service = bluetooth_LE_Device.GetGattServicesAsync();
if (result_service.Status == await GattCommunicationStatus.Success)
{
var services = result_service.Services;
// ...
}
}
I am using UwpDesktop package.
I had the same problem. My problem was solved after I changed the reference to windows.winmd from C:\Program Files (x86)\Windows Kits\10\UnionMetadata\windows.winmd to C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0\windows.winmd.
I'm using BLE 4.0 in a WinForm application and I'm working with Visual Studio 2017.
It is very likely that the directory 10.0.17763.0 doesn't exist on every computer, but you may look what versions of windows.winmd exists on your computer.
I've started using the Xamarin UITest to verify the behaviour of my application. I wanted to make the tests logically separated (by that I mean, if one test fails the other one should not fail because of the first, they should be independent). My application has multiple activities and I could not find in the documentation how to open a specific Activity.
The closest I could find was:
[SetUp]
public void BeforeEachTest()
{
app = ConfigureApp.Android.LaunchableActivity("MyActivity").StartApp ();
}
But nothing happend. Can I do this? Is there a workaround?
Thanks
A very late response but thought i'd put it up for others to find. In order to launch the app using a specific activity UITest requires two pieces of information, the app name (or APK file path) and the activity name.
Calling StartApp() on the AndroidConfigurator will look as follows for an app that is already installed onto the device or emulator:
app = ConfigureApp
.Android
.InstalledApp("packagename")
.LaunchableActivity("activityname")
.StartApp();
Or as follow for an APK file:
app = ConfigureApp
.Android
.ApkFile("filename")
.LaunchableActivity("activityname")
.StartApp();
try this code:
if (platform == Platform.Android)
{
string currentFile = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
FileInfo fi = new FileInfo(currentFile);
string dir = fi.Directory.Parent.Parent.Parent.FullName;
var PathToAPK = Path.Combine(dir, "LetsGetNative.Droid", "bin", "Debug", "LetsGetNative.Droid.apk");
app = ConfigureApp.Android.ApkFile(PathToAPK).WaitTimes(new WaitTimes()).EnableLocalScreenshots().StartApp();
}
else
{
app = ConfigureApp.iOS.StartApp();
}
I am using Telerik reports in our app and it is being accessed mostly through an RDP session running in "app mode". Everything works fine locally but when I put it on the TS machine it freezes after the print dialog comes up.
The standard print dialog comes up and you can choose the printer and hit ok but then a small box opens with header of Printing... and then never does anything.
I am not sure what code to post since its fine locally, let me know what you want to see. also printing other things like the Telerik grids and charts are fine.
Found the answer on my own.
I created a standard printdialog screen and "rolled my own" print method and all seems to be good. Hope this helps someone else.
private void reportViewer1_Print(object sender, CancelEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
e.Cancel = true;
try
{
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
var result = pd.ShowDialog();
if (result ==DialogResult.OK)
{
// Print the report using the custom print controller
var reportProcessor
= new Telerik.Reporting.Processing.ReportProcessor();
reportProcessor.PrintReport(this.reportViewer1.ReportSource, pd.PrinterSettings);
}
}
catch (Exception ex)
{
Program.ExceptionHandler(ex);
}
this.Cursor = Cursors.Default;
}