Giter Site home page Giter Site logo

nativescript-receiving-shared-content's People

Contributors

nickiliev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nativescript-receiving-shared-content's Issues

How about other file types?

Hi, I'm so tired that I can't find a way to receive a CSV file. Is that impossible or what?

All I can get is content://the.sender.app.provider/internalCache/the-file-i-want-to-open.csv

How can I use the imageUri in my project

Hi I'm using your implementation in nativescript-angular project.
and I want to use share and upload the shared images to my server.

How can I show the selected images in images slider, but there is exception that content://....... URI is cannot be displayed.

Requesting an update

Really learned a lot from this repo. Any chance to request an update to it now that app extensions are supported in nativescript?

Error on creating activityCreatedEvent

Hi all, here. I am running NS8 and just in case if someone runs into problems, here is example with correct imports.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// var page_1 = require("@nativescript/core/ui").Page;
const Observable = require("@nativescript/core").Observable;
const application = require("@nativescript/core/application");
// sve gore dodano

import { Application } from '@nativescript/core'

import { HomeViewModel } from './home-view-model'

// dodano
var vm = new Observable();

export function onNavigatingTo(args) {
  const page = args.object
  page.bindingContext = new HomeViewModel()
  // dole ubaceno
  page.bindingContext = vm;
  vm.set("sharedText", "testiram abc");
  if (application.android) {
    vm.set("sharedText", "Ovo je android!");
    application.android.on(application.AndroidApplication.activityCreatedEvent, function (args) {
      // application.android.on(application.AndroidApplication.startActivity., function (args) {
        var activity = args.activity;
        console.log("Pokrenuta aplikacija i ovo su podaci:");
        console.log(activity);
        vm.set("sharedText", "Stigli podaci");
        // Get intent, action and MIME type
        var intent = activity.getIntent();
        var action = intent.getAction();
        var type = intent.getType();
        if (android.content.Intent.ACTION_SEND === action && type != null) {
            if (type.startsWith("text/")) {
                handleSendText(intent); // Handle text being sent
            }
            else if (type.startsWith("image/")) {
                handleSendImage(intent); // Handle single image being sent
            }
        }
        else if (android.content.Intent.ACTION_SEND_MULTIPLE === action && type != null) {
            if (type.startsWith("image/")) {
                handleSendMultipleImages(intent); // Handle multiple images being sent
            }
        }
        else {
            // Handle other intents, such as being started from the home screen
        }
    });
  }
  // gore ubaceno
}

// donje funkcije ubacene
function handleSendText(intent) {
  if (application.android) {
      var sharedText = intent.getStringExtra(android.content.Intent.EXTRA_TEXT);
      if (sharedText != null) {
          // Update UI to reflect text being shared
          console.log("sharedText: ", sharedText);
          console.log("Text received!");
          // delay is needed to update UI after loading the app
          setTimeout(func, 1000);
          function func() {                  
              vm.set("sharedText", sharedText);
          }
      }
  }
}
function handleSendImage(intent) {
  if (application.android) {
      var imageUri = intent.getParcelableExtra(android.content.Intent.EXTRA_STREAM);
      if (imageUri != null) {
          // Update UI to reflect image being shared
          console.log("Image received!");
          var appContext = application.android.context;
          var bitmap = android.provider.MediaStore.Images.Media.getBitmap(appContext.getContentResolver(), imageUri);
          console.log("bitmap: ", bitmap);
          vm.set("bitmap", bitmap);
      }
  }
}
function handleSendMultipleImages(intent) {
  if (application.android) {
      var imageUris = intent.getParcelableArrayListExtra(android.content.Intent.EXTRA_STREAM);
      if (imageUris != null) {
          // Update UI to reflect multiple images being shared
          console.log("imageUris: ", imageUris);
          console.log("Multiple images received!");
      }
  }
}

// gorenj funkcije ubacene
export function onDrawerButtonTap(args) {
  const sideDrawer = Application.getRootView()
  sideDrawer.showDrawer()
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.