johnjohndoe / android-developers-samples Goto Github PK
View Code? Open in Web Editor NEWTracking changes for Android Developers Samples
Home Page: https://developer.android.com/samples/index.html
Tracking changes for Android Developers Samples
Home Page: https://developer.android.com/samples/index.html
Where can I find BasicFragment
class in the test class for ActionBarCompat-Basic sample?
I can't compile SampleTests.java
to save my life since it can't resolve BasicFragment
to a type. Anyone have any clues? Thanks in advance...
In my android application, I have an option to print the invoices for the delivery order. I am generating the Invoice content as html and sending it to android print manager as a string to print it. It is getting opened in print dialog and I am able to select a printer for printing. But after the print, my application is getting closed. But I want to redirect to the same page after the print.
Also I want to set the number of copies to 2 while printing programmatically from the android print manager. This is my source code.
private void print() {
// Create a WebView and hold on to it as the printing will start when
// load completes and we do not want the WbeView to be garbage collected.
mWebView = new WebView(this);
// Important: Only after the page is loaded we will do the print.
mWebView.setWebViewClient(new WebViewClient() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onPageFinished(WebView view, String url) {
doPrint();
}
});
mWebView.loadDataWithBaseURL(null, htmlDocument, "text/HTML", "UTF-8", null);
// Load an HTML page.
// mWebView.loadUrl("file:///android_res/raw/motogp_stats.html");
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void doPrint() {
// Get the print manager.
PrintManager printManager = (PrintManager) getSystemService(
Context.PRINT_SERVICE);
// Create a wrapper PrintDocumentAdapter to clean up when done.
PrintDocumentAdapter adapter = new PrintDocumentAdapter() {
private final PrintDocumentAdapter mWrappedInstance =
mWebView.createPrintDocumentAdapter();
@Override
public void onStart() {
mWrappedInstance.onStart();
}
@Override
public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes,
CancellationSignal cancellationSignal, LayoutResultCallback callback,
Bundle extras) {
mWrappedInstance.onLayout(oldAttributes, newAttributes, cancellationSignal,
callback, extras);
}
@Override
public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) {
mWrappedInstance.onWrite(pages, destination, cancellationSignal, callback);
}
@Override
public void onFinish() {
mWrappedInstance.onFinish();
// Intercept the finish call to know when printing is done
// and destroy the WebView as it is expensive to keep around.
mWebView.destroy();
mWebView = null;
}
};
try{
// Pass in the ViewView's document adapter.
printManager.print("MotoGPstats", adapter, null);
// printManager.print("MotoGP stats", mWebView.createPrintDocumentAdapter(), null);
Log.i("MotoGPstats",""+mWebView.createPrintDocumentAdapter());
Log.i("printtest",""+adapter);
}catch (NullPointerException n){
n.getMessage();
}
}
Hi great code!!
I have a problem. if i have 2 build types release and debug for example, how can i change the syncadapter authority????
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.