Android, How to read QR code in my application?

try { Intent intent = new Intent(“com.google.zxing.client.android.SCAN”); intent.putExtra(“SCAN_MODE”, “QR_CODE_MODE”); // “PRODUCT_MODE for bar codes startActivityForResult(intent, 0); } catch (Exception e) { Uri marketUri = Uri.parse(“market://details?id=com.google.zxing.client.android”); Intent marketIntent = new Intent(Intent.ACTION_VIEW,marketUri); startActivity(marketIntent); } and in onActivityResult(): @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 0) { if (resultCode … Read more

Scala: Implicit parameter resolution precedence

I wrote my own answer in the form of a blog post revisiting implicits without import tax. Update: Furthermore, the comments from Martin Odersky in the above post revealed that the Scala 2.9.1’s behavior of LocalIntFoo winning over ImportedIntFoo is in fact a bug. See implicit parameter precedence again. 1) implicits visible to current invocation … Read more

Implicit keyword before a parameter in anonymous function in Scala

There are two distinct features here. First, request isn’t really an argument in a method invocation. It’s the argument of an anonymous function. The anonymous function itself is the argument of the method invocation. Second, declaring an implicit argument in an anonymous function have the convenience of saving you from “forcing” a val into a … Read more

ReSharper and var [duplicate]

Resharper is primarily concerned with helping you refactor code, and the var keyword generally makes refactoring easier. For example, if the return values of any of those functions ever change to a compatibile type, you don’t have to change any of this code. It’s therefore now a little easier to refactor your tabCaseNotes type, for … Read more

Can we define implicit conversions of enums in c#?

There is a solution. Consider the following: public sealed class AccountStatus { public static readonly AccountStatus Open = new AccountStatus(1); public static readonly AccountStatus Closed = new AccountStatus(2); public static readonly SortedList<byte, AccountStatus> Values = new SortedList<byte, AccountStatus>(); private readonly byte Value; private AccountStatus(byte value) { this.Value = value; Values.Add(value, this); } public static implicit … Read more

Why do members of a static class need to be declared as static? Why isn’t it just implicit?

I get asked questions like this all the time. Basically the question boils down to “when a fact about a declared member can be deduced by the compiler should the explicit declaration of that fact be (1) required, (2) optional, or (3) forbidden?” There’s no one easy answer. Each one has to be taken on … Read more

In scala 2 or 3, is it possible to debug implicit resolution process in runtime?

You can debug implicits at compile time: switch on compiler flag -Xlog-implicits try to resolve implicits manually (maybe specifying type parameters as well) and see compile errors implicitly[…](…manually…) use scala.reflect println(reify { implicitly[…] }.tree) (or switch on compiler flag -Xprint:typer) in order to see how implicits are resolved use IDE functionality to show implicits using … Read more

tech